home *** CD-ROM | disk | FTP | other *** search
- /*[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]*/ /* Pasmat format control line */
- /* UMacApp.p */
- /* Copyright © 1984-1990 by Apple Computer Inc. All rights reserved. */
-
- /* ??? Comments that contain '???' (such as this one) indicate issues that need
- to be resolved sooner or later. ???
- The MacApp® team wishes to thank MADA, Carl Nelson, Robin Mair and Jeff Alger for
- generously allowing us to us the MADA MacApp 2.0 Condensed reference text freely.
- This has allowed us to document a number of "historical" interfaces. */
- #ifndef __UMacApp__
- #define __UMacApp__ 0
- #endif
- #if ! __UMacApp__
- #define __UMacApp__ 1
-
- /* • Required for this unit's interface. Auto-Include them */
- #ifndef __UMacAppUtilities__
- #include "UMacAppUtilities.h"
- #endif
- #ifndef __UObject__
- #include "UObject.h"
- #endif
- #ifndef __UList__
- #include "UList.h"
- #endif
- #ifndef __UAssociation__
- #include "UAssociation.h"
- #endif
- #ifndef __UFailure__
- #include "UFailure.h"
- #endif
- #ifndef __UPatch__
- #include "UPatch.h"
- #endif
- #ifndef __UMemory__
- #include "UMemory.h"
- #endif
- #ifndef __UMenuSetup__
- #include "UMenuSetup.h"
- #endif
- #ifndef __UViewCoords__
- #include "UViewCoords.h"
- #endif
- #ifndef __SCRAP__
- #include "Scrap.h"
- #endif
- #ifndef __WINDOWS__
- #include "Windows.h"
- #endif
- #ifndef __DIALOGS__
- #include "Dialogs.h"
- #endif
-
- const unsigned char kCopyright[] =
- "\pMacApp® 2.0.1 Copyright © 1984-1990 Apple Computer, Inc. All rights reserved."
- ;
-
- /* M E N U S */
- const short kMBarDisplayed = 128; /* Default 'MBAR' id of the menus that are
- read in and installed in menu bar */
- const short kMBarNotDisplayed = 129; /* Default 'MBAR' id of the menus that are
- read in but not installed */
- const short kMBarHierarchical = 130;
- /* Default 'MBAR' id of the menus that pop up
- when a menu item is choosen */
-
- /* C O M M A N D S */
-
- /* Negative numbers and positive numbers up to 999 are reserved by MacApp */
- /* Predefined command numbers ??? Renumber these more logically ??? */
- /* Not all of these are caught by MacApp.
- "<!>" means MacApp catches it.
- "<&>" means TEView catches it.
- "<->" means the application must catch it if it is used as a
- command number in any menu."
- {Special command codes */
-
- const short cNoCommand = 0;
- /* <!> Command number representing no command
- */
- const short cCantUndo = - 1; /* <!> Passed to TApplication.SetUndoText to
- indicate that the command cannot be
- undone. */
-
- /* Apple-menu commands */
-
- const short cAboutApp = 1; /* <!> "About <appname>…" */
-
- /* File-menu filing commands */
-
- const short cNew = 10; /* <!> "New" (??? reserve a range of NEW
- commands ???) */
- const short cNewLast = 19;
- const short cOpen = 20; /* <!> "Open …" (??? reserve a range of OPEN
- commands ???) */
- const short cOpenLast = 29;
-
- const short cSave = 30; /* <!> "Save" */
- const short cClose = 31; /* <!> "Close" */
- const short cSaveAs = 32; /* <!> "Save as…" */
- const short cSaveCopy = 33; /* <!> "Save a Copy in …" */
- const short cRevert = 34; /* <!> "Revert" (to previous version) */
- const short cShowClipboard = 35; /* <!> "Show Clipboard"/"Hide Clipboard" */
- const short cQuit = 36; /* <!> "Quit" */
-
- /* Edit-menu commands */
-
- /* For the following command numbers, we must guarantee that
- <command number> - cEditBase = <appropriate number to pass to
- SystemEdit>. This relationship is enforced in
- TApplication.IApplication. */
- const short cEditBase = 101; /* start of standard editing commands */
- const short cUndo = 101; /* <!> "Undo <command>"/"Redo <command>" */
- const short cEditSep = 102; /* line separating UNDO from CUT */
- const short cCut = 103; /* <&> "Cut" */
- const short cCopy = 104; /* <&> "Copy" */
- const short cPaste = 105; /* <&> "Paste" */
- const short cClear = 106; /* <-> "Clear" */
- const short cEditLast = cClear;
-
- const short cSelectAll = 110; /* <&> "Select All" */
-
- const short cTyping = 120; /* for use in a TTypingCommand */
- const short cMouseCommand = 121; /* generic mouse command */
-
- const short cStyleChange = 130; /* "Menu" command for style change */
- const short cRememberStyle = 131; /* "Menu" command for remembering present
- style */
-
- /* Finder pseudo-commands */
-
- const short cFinderNew = 40;
- /* <!> The user selected the tool icon in the
- Finder and chose "Open" */
- const short cFinderPrint = 41; /* <!> The user selected document icons in
- the Finder and chose "Print" */
- const short cFinderOpen = 42; /* <!> The user selected document icons in
- the Finder and chose "Open" */
-
- /* File-menu printing commands */
-
- const short cPrFileBase = 176; /* Command numbers between cPrFileBase and
- cPrFileMax are sent to a document's
- fDocPrintHandler even if it is not in the
- fTarget chain */
- const short cPrFileMax = 195;
-
- const short cPageSetup = 176; /* <!> "Page Setup…" */
- const short cPrintOne = 177; /* <!> "Print One" */
- const short cPrint = 178; /* <!> "Print…" */
- const short cPrintToFile = 179; /* <!> "Print to file…" */
-
- const short cPrintSpoolFile = 190; /* <-> "Print spooled file…" */
-
- const short cPrViewBase = 201; /* Command numbers between cPrViewBase and
- cPrViewMax are printing commands applied
- to a displayed view in the fTarget chain */
- const short cPrViewMax = 250;
-
- const short cShowBorders = 199; /* <!> Toggle. "Show view borders"--also
- usable outside Debug menu */
-
- /* Zooming commands */ /* Not being used at present */
-
- const short cReduce50 = 301; /* <-> "Reduce 50%" */
- const short cReduceToFit = 302; /* <-> "Reduce to Fit" */
- const short cShowFullSize = 303; /* <-> "Show Full Size" */
-
- /* Control tracking */
- const short cTrackingControl = 400;
-
- /* Debug-menu commands. Flag toggled by "cFoo" is called "gFoo" for any
- "Foo" */
-
- const short cIdentifySoftware = 900; /* <!> Action. "Show Software Version"--
- WriteLn version info */
- const short cExperimenting = 901;
- /* <!> Toggle. "Enable experimental features"
- */
- const short cReportMenuChoices = 902; /* <!> Toggle. "Trace menu commands"--
- WriteLn menu choices */
- const short cIntenseDebugging = 904; /* <!> Toggle. "Intense Debugging" */
- const short cTraceSetupMenus = 905; /* <!> Toggle. "Allow Trace of Menu Setups"
- if gTrace is also on */
- const short cTraceIdle = 906; /* <!> Toggle. "Allow Trace during Idle" if
- gTrace is also on */
- const short cDebugPrinting = 912; /* <!> Toggle. "Debug Printing" */
- const short cReportEvt = 914; /* <!> Toggle. "Report Events"--WriteLn
- events received from queue */
- const short cDoFirstClick = 915; /* <!> Toggle. "'Do First Click' for this
- window" */
- const short cVarClipPicSize = 916; /* <!> Toggle. "Scale Pictures in Clipboard
- to Window" */
- const short cRefreshFrontWindow = 917; /* <!> Action. "Refresh Front Window" */
- const short cNewInspectorWindow = 918;
- /* <!> Action. "Open new inspector window" */
- const short cModalToggle = 919; /* <!> Toggle. "Make front window
- modal/modeless"*/
- const short cDebugWind = 913; /* <!> Action. "Show Debug Window" */
- const short cEnterMacAppDebugger = 920;
- /* <!> Action. "Enter the MacApp Debugger" */
-
- const short cSetSysJust = 921;
- /* <!> Action. "Switch system justification" */
-
-
- /* D E B U G F L A G S */
-
- #if ! qDebug /* These start with 'g' because they are
- global variables when qDebug is TRUE */
- const short gExperimenting = false;
- const short gReportMenuChoices = false;
- const short gIntenseDebugging = false;
- const short gDebugPrinting = false;
- const short gReportEvt = false;
-
- const short gMemMgtReport = false;
- const short gAssumeFocused = false;
- #endif
-
- /* A L E R T S */
-
- const short errReasonID = 128; /* resource ID of errs resource describing
- error messages */
- const short errRecoveryID = 129; /* resource ID of errs resource describing
- recovery messages */
- const short errOperationsID = 130; /* resource ID of errs resource containing
- operation strings */
- const short errAppTable = 1000;
- /* added to the MacApp resource ID to get the
- ID of an application error table */
-
- const short msgCmdErr = 0; /* when added to a command number, gives a
- message value to display the alert "Could
- not complete the … command …" */
- const long msgAlert = 0xFFFF0000; /* when added to an alert number, gives a
- message value to display that alert */
- const long msgLookup = 0xFFFE0000; /* when added to an INTEGER, gives a message
- value that will look up the INTEGER in
- table errOperationsID and display the
- alert "Could not … because …" */
- const long msgAltRecovery = 0xFFFD0000; /* same as msgLookup, except the INTEGER is
- used instead of the error number to lookup
- the recovery string */
-
- const long msgStrList = 130 * 0x10000;
- /* Standard list of operation strings used by
- MacApp * $10000 to plunk it into hiwrd */
- const long msgCancelled = msgStrList; /* used with error = noErr if user cancels
- Save, Quit, … */
- const long msgInitFailed = msgStrList + 1;
- const long msgSaveFailed = msgStrList + 2;
- const long msgRevertFailed = msgStrList + 3;
- const long msgPrintFailed = msgStrList + 4;
- const long msgNewFailed = msgStrList + 5;
- const long msgOpenFailed = msgStrList + 6;
- const long msgSaveAsFailed = msgStrList + 7;
- const long msgSaveCopyFailed = msgStrList + 8;
- const long msgDrawFailed = msgStrList + 9;
- const long msgImportClipFailed = msgStrList + 10;
- const long msgExportClipFailed = msgStrList + 11;
-
- /* error codes used in MacApp; applications should use errors between
- -25000 and -29999 */
-
- const short errSpooling = - 20000; /* print spooling failed OSErr */
- const short errRevertFNF = - 20001; /* Revert failed because file was deleted */
- const short errFileChanged = - 20002; /* disk file modification date changed */
- const short errSaveAgain = - 20003; /* Save As / Save a Copy in an opened
- document */
- const short errFTypeChanged = - 20004; /* disk file type changed */
- const short errNoPrintDrvr = - 20005; /* print driver file not found */
- const short errNotMyType = - 20006; /* can't open this file type */
- const short errNotImplemented = - 20007; /* Signaled when a function is not yet
- implemented */
- const short errMissingClass = - 20008; /* Signaled when a class is missing. Usually
- due to failure to dead-strip suppress when
- creating objects any other way than by "NEW" */
-
- /* Alerts 0 - 249 are reserved by MacApp. */
-
- const short phGenError = 128; /* 'Could not ^2, because ^0. ^1' */
- const short phCmdErr = 129; /* 'Could not complete the “^2” command
- because ^0. ^1'. */
- const short phUnknownErr = 130; /* 'Could not complete your request because
- ^0. ^1'; only used if no operation is
- supplied. */
- const short phSaveChanges = 131; /* 'Save Changes Before Closing?' */
- const short phRevert = 132; /* 'Revert to last version saved?' */
- const short phFileChanged = 133; /* 'File changed since last save.' */
- const short phPurgeOld = 134;
- /* 'OK to purge old version before saving new
- one?' */
- const short phReopenDoc = 135; /* 'Document is already open.' */
- const short phSpaceIsLow = 136; /* 'Space is low' */
- const short phUnsupportedConfiguration = 137; /* 'Can't start app because your machine is
- too wimpy!' */
- const short phOfferReadOnly = 138; /* 'Can't open for file for write. Open
- read-only?' */
-
- const short phTooManyChars = 150; /* 'Too Many Characters', used to reject
- paste or keystrokes in UDialog and UTEView
- */
-
- const short phStylesTooBig = 151; /* 'Too Many Styles', used to reject the
- styles portion of a paste in UTEView */
-
- const short phAboutApp = 201;
- /* Can hold the 'About <appName>…' message */
-
- const short phUnimplemented = 202; /* 'This feature not yet implemented' */
-
- /* M A C A P P B U Z Z - S T R I N G R E S O U R C E */
- const short kIDBuzzString = 250; /* std list of buzzwords stored as 'STR#'
- resources. This string list is reserved
- for MacApp; you should choose a different
- resource ID for your strings. */
-
- /* Indices for strings in the buzz-string resource */
- const short bzSaveAs = 1; /* 'Save This Document As:' */
- const short bzSaveCopy = 2; /* 'Save a Copy In:' */
- const short bzShowClip = 3; /* 'Show Clipboard' */
- const short bzHideClip = 4; /* 'Hide Cllpboard' */
- const short bzUndo = 5; /* 'Undo x' */
- const short bzRedo = 6; /* 'Redo x' */
- const short bzCantDraw = 7; /* 'Unable to draw contents of window' */
- const short bzUntitled = 8; /* name of untitled document; if blank then
- this is taken from the window title
- template; if this includes the string
- '<<<>>>' then MacApp will substitute a
- number for the string (e.g., if the buzz
- string contains 'Untitled-<<<>>>' then
- untitled windows will be named
- 'Untitled-1', Untitled-2, … */
- const short bzClosing = 9; /* 'closing' */
- const short bzQuitting = 10; /* 'quitting' */
- const short bzCantUndo = 11; /* 'Can’t Undo' */
- const short bzSaveAnyways = 12; /* 'save' */
- const short bzRevertAnyways = 13; /* 'revert' */
-
- /* D E B U G B U Z Z - S T R I N G R E S O U R C E */
- const short kDebugBuzzStrings = 251; /* Debug buzzwords STR# resource */
- const short bzMakeModal = 1; /* 'Make Front Window Modal' */
- const short bzMakeModeless = 2; /* 'Make Front Window Modeless' */
- const short bzDoFirstClick = 3; /* 'Do First Click For This Window' */
- const short bzDontDoFirstClick = 4; /* 'Don't Do First Click For This Window' */
- const short bzSetRightSysJust = 5; /* Set system to right justification */
- const short bzSetLeftSysJust = 6; /* Set system to left justification */
-
- /* R E S O U R C E I D S */
- /* Negative numbers and numbers up to 127 are reserved by Apple */
- /* Positive numbers from 128 up to 999 are reserved by MacApp */
- const short kDefaultCredits = 1001; /* People responsible for the application */
- const short kIDClipWindow = 200; /* window displaying the Clipboard */
- const short kScrollBarId = 202; /* for when we create scrollers from
- resources */
- const short kDebugParamsID = 300; /* debug window */
-
- /* V I E W I D E N T I F I E R S */
- /* These follow the same reservation rules as resource types */
-
- const short kDefaultWindowID = 1001; /* Window view resource installed by default
- in TDocument */
- const short kDefaultViewID = 1002; /* View resource installed by default in
- TDocument */
- const unsigned long kIDDefaultView = 'DFLT'; /* View ID of default view */
- const unsigned long kIDClipView = 'CLIP'; /* identifier of the clipboard "orhanage" */
-
- /* O B J E C T S I G N A T U R E S */
- /* These follow the same reservation rules as resource types */
- /* The signature is used to search the signature table and create
- an object "by signature" If the signature's entry in the table has
- been updated with a new class then an object of that class will be created. */
-
- const unsigned long kStdDocument = 'docu';
- const unsigned long kStdTracker = 'trak';
- const unsigned long kStdList = 'list';
-
- const unsigned long kStdButton = 'butn';
- const unsigned long kStdCheckBox = 'chkb';
- const unsigned long kStdCluster = 'clus';
- const unsigned long kStdControl = 'cntl';
- const unsigned long kStdDefaultView = 'dflt';
- const unsigned long kStdDialogView = 'dlog';
- const unsigned long kStdEditText = 'edit';
- const unsigned long kStdGridView = 'grid';
- const unsigned long kStdIcon = 'icon';
- const unsigned long kStdNumberText = 'nmbr';
- const unsigned long kStdPattern = 'patn';
- const unsigned long kStdPicture = 'pict';
- const unsigned long kStdPopup = 'popp';
- const unsigned long kStdRadio = 'radb';
- const unsigned long kStdScroller = 'scrl';
- const unsigned long kStdSScrollBar = 'sbar';
- const unsigned long kStdStaticText = 'stat';
- const unsigned long kStdTEView = 'tevw';
- const unsigned long kStdTextGridView = 'txtg';
- const unsigned long kStdTextListView = 'lstg';
- const unsigned long kStdView = 'view';
- const unsigned long kStdWindow = 'wind';
-
- /* H I G H L I G H T I N G */
- const short hlOff = 1; /* the selection is to be unhighlighted */
- const short hlDim = 2;
- /* the selection is to be dimly highlighted */
- const short hlOn = 4;
- /* the selection is to be fully highlighted */
-
- /* these constants can be used to test for combinations of fromHL+toHL,
-
- when you do not care which is from and which is to */
- const short hlOffDim = hlOff + hlDim;
- const short hlDimOff = hlOffDim;
- const short hlDimOn = hlDim + hlOn;
- const short hlOnDim = hlDimOn;
- const short hlOffOn = hlOff + hlOn;
- const short hlOnOff = hlOffOn;
-
- /* C H O I C E S */
-
- /* Negative numbers and positive numbers up to 999 are reserved by MacApp */
- const short mOKHit = 1;
- const short mCancelHit = 2;
- const short mButtonHit = 3;
- const short mCheckBoxHit = 4;
- const short mClusterHit = 5;
- const short mEditTextHit = 6;
- const short mIconHit = 7;
- const short mListItemHit = 8;
- const short mListScrollBarHit = 9;
- const short mPictureHit = 10;
- const short mPopupHit = 11;
- const short mRadioHit = 12;
- const short mStaticTextHit = 13;
- const short mHScrollBarHit = 14;
- const short mVScrollBarHit = 15;
- const short mEditTabKey = 16;
- const short mEditReturnKey = 17;
- const short mEditEnterKey = 18;
- const short mPatternHit = 19;
- const short mControlHit = 20;
- const short mCancelKey = 21;
- const short mDefaultKey = 22;
-
- const unsigned long kNoIdentifier = ' ';
- const short kNoTemplate = - 1;
- const short kNoResource = - 1;
-
- /* M I S C E L L A N E O U S */
- const unsigned long kStdMainFileType = 'TEXT';
- /* the file type identifier used by default */
-
- const short kYesButton = 1; /* the 'Yes' button in various dialogs */
- const short kNoButton = 3; /* the 'No' button in various dialogs */
-
- const short kLowSpaceInterval = 2 * 60 * 60;
- /* default low space msg interval (2 seconds)
- */
-
- const short kStdScrollUnit = 16; /* default value of fScrollUnit used by
- scrollers */
-
- const short kSBarSize = 16;
- const short kSBarSizeMinus1 = kSBarSize - 1;
- /* !!! Prefer the above names */
- const short kStdSzSBar = 16; /* width/height of a standard
- vertical/horizontal scroll bar */
- const short kStdSzMinus1SBar = kStdSzSBar - 1;
-
- const short kStdStaggerAmount = 16;
- /* standard # of pixels to stagger windows */
-
- const unsigned long kMaxIdleTime = LONG_MAX; /* Default tick count sent to WaitNextEvent */
-
- /* Numbers to pass to SystemEdit */
- const short kSysUndo = 0;
- const short kSysCut = 2;
- const short kSysCopy = 3;
- const short kSysPaste = 4;
- const short kSysClear = 5;
-
- #if qDebug
- const short kRsrcCheckInterval = 100;
- #endif
- const short kPriorityLowest = 127; /* Low priority commands are considered last
- */
- const short kPriorityLow = kPriorityLowest - 32; /* Low priority commands are considered last
- */
- const short kPriorityNormal = 64; /* Normal priority assigned to commands by
- default */
- const short kPriorityHighest = 0; /* High priority commands take precedence */
- const short kPriorityHigh = kPriorityHighest + 32; /* High priority commands take precedence */
-
- const short kBuild = true; /* Pass to TWindow.BuildWindowRgns */
- const short kAllowApplicationToSleep = true; /* Pass to TApplication.PollEvent if the
- application is allowed to sleep if there
- are no events pending. */
- /* P R I N T I N G */
- const short kSquareDots = true; /* Square dots in Printing */
- const short kFixedSize = true; /* Fixed Page Size in Printing */
-
- const short kPrintInfoSize = 120; /* size in bytes of printInfo record */
-
- /* size in bytes of the overhead for a resource file;
- kRsrcFileOverhead is added in TDocument.DoNeedDiskSpace if the
- document uses the rsrc fork.
- You should add kRsrcTypeOverhead for each unique type you use
- plus kRsrcOverhead for each resoruce you use
- plus the total bytes in all the resources
- plus the length of all the names for named resources. */
- const short kRsrcFileOverhead = 256 + /* resource header & stuff */
- 30 /* fixed part of resource map */ ;
- const short kRsrcTypeOverhead = 8; /* overhead for each resource type */
- const short kRsrcOverhead = 16; /* overhead for each resource */
-
- /* ??? */
- const short kViewRsrcExpandAmt = 0x400; /* ??? Is 1K enough for expansion, or too
- much maybe??? */
-
- /* debugging info */
- const short kDebugFont = /*monaco*/ 4; /* Font for Debug Window */
- const short kDebugSize = 9; /* Font size for Debug Window */
-
- /* argument of TDocument.DoMakeViews */
- const short kForDisplay = false;
- const short kForPrinting = ! kForDisplay;
-
- /* arguments of TScroller.IScroller */
- const short kWantHScrollBar = true;
- const short kWantVScrollBar = true;
-
- /* arguments of TDocument.Save */
- const short kAskForFilename = true;
- const short kMakingCopy = true;
- const short kSwitchToTarget = ! kMakingCopy;
-
- /* argument of NewPaletteWindow */
- const short kLeftPalette = h;
- const short kTopPalette = v;
-
- /* argument of TApplication.SetUndoText */
- const short kShowUndo = true;
- const short kShowRedo = false;
- const short kShowCantUndo = kShowUndo;
-
- /* argument of TDocument.IDocument */
- const short kUsesDataFork = true;
- const short kUsesRsrcFork = true;
- const short kDataOpen = true;
- const short kRsrcOpen = true;
-
- /* argument of TDocument.OpenDocFile */
- const short kKeepingOpen = true;
- const short kReadingFile = true;
-
- const short kVisible = true;
- const short kInvisible = false;
-
- /* arguments to routines with a 'redraw' parameter */
- const short kRedraw = true;
- const short kDontRedraw = false;
-
- /* arguments to routines with an 'invalidate' parameter */
- const short kInvalidate = true;
- const short kDontInvalidate = false;
-
- /* MultiFinder event message masks */
- const short kSuspendOrResume = 0x01;
- const short kMouseMovedMessage = 0xFA;
-
- const short kMaxSignatures = 32;
-
- /* E V E N T S */
-
- typedef EventRecord *EventRecordPtr;
- /* EventRecord is a ToolBox type. The pointer
- type _MUST_ be declared first since the
- record is self referential */
- struct EventInfo {
- /* stores more information about the event in
- an unpacked form */
- EventRecordPtr thePEvent; /* pointer to the original packed ToolBox
- event record */
- Boolean theBtnState; /* bits found in the modifiers field of an
- EventRecord */
- Boolean theCmdKey; /* Was Command key depressed? */
- Boolean theShiftKey; /* Was Shift key depressed? */
- Boolean theAlphaLock; /* Was Alpha Lock depressed? */
- Boolean theOptionKey; /* Was Option key depressed? */
- Boolean theControlKey; /* Was Control key depressed? */
- Boolean theAutoKey; /* TRUE if this was an auto key event */
- short theCharacter; /* IF a key event the char that the event
- translates to !!! what about 16
- bit chars? */
- short theKeyCode;
- /* IF a key event the virtual key code that the
- event translates to */
-
- short theClickCount;
- /* 0 = event was not a mouse down; 1-N = # of
- multiple clicks */
- Boolean affectsMenus; /* True means the menus must be setup after
- the event */
- };
- typedef EventRecordPtr PEventRecord; /* Left in for compatibility (2.0) */
-
- typedef enum {idleBegin, idleContinue, idleEnd} IdlePhase;
- typedef enum {trackPress, trackMove, trackRelease} TrackPhase;
-
- /* V I E W C O O R D I N A T E S */
-
- typedef enum {sizeSuperView, sizeRelSuperView, sizePage, sizeFillPages, sizeVariable, sizeFixed}
- SizeDeterminer;
- /* No special default handling of size issues
- */
-
- /* H I G H L I G H T I N G */
- typedef unsigned char HLState;
-
- /* D O C U M E N T S */
- /* How to save a document in place, if MacApp decides this is needed.
- sipNever: never save on top of old file (ie., save will fail if
- there is not enough disk space)
- sipAlways: save on top of old file without asking user
- sipAskUser: save on top, but only if user confirms
- */
- typedef enum {sipNever, sipAlways, sipAskUser} SIPChoice;
-
- /* O T H E R */
- typedef AppFile *AppFilePtr; /* AppFile is segment loader section of
- Inside Macintosh */
- typedef AppFilePtr PAppFile; /* Left in for compatibility (2.0) */
-
- typedef OSType ArrTypeList[8000];
- typedef ArrTypeList *TypeListPtr; /* Preferred */
- typedef TypeListPtr *TypeListHandle; /* Preferred */
- typedef TypeListPtr PTypeList; /* Left in for compatibility (2.0) */
- typedef TypeListHandle HTypeList; /* Left in for compatibility (2.0) */
-
- typedef unsigned char CommandPriority; /* Command priorities */
-
- class TEvtHandler : public TObject {
- public: /* The TEvtHandler type represents abstract
- objects that handle certain kinds of
- events: Key events: both key down and auto
- key events, menu events: both enabling
- menus and menu items and processing menu
- commands, Read to/write from Disk, Idle
- events: when there are no other events to
- handle, Actual events: EvtHandlers -
- through their method 'DoHandleEvent' may
- intercept and handle actual ToolBox events
- Termination: when the application quits
- TEvtHandler are linked into a list with
- the most specific object (usually a
- selection) at the head of the list. The
- global variable 'gTarget' contains the
- head of the list. (When a window is
- deactivated, this global variable is
- cached in the window object, and retrieved
- when it is later activated.) For these
- kinds of events, the target (gTarget) gets
- the first crack at handling the event. The
- default implementation of the methods of
- TEvtHandler is to pass the event to the
- next element of the list. */
-
- TEvtHandler *fNextHandler; /* the next element of the list, or NIL */
- long fIdleFreq; /* the minimum number of ticks that can pass
- before my DoIdle is called. 0 = call as
- often as possible. n..kMaxIdleTime = call
- every fIdleFreq ticks. */
- long fLastIdle;
- /* the tick count the last time my DoIdle was
- called. */
-
- /* Init & Free */
- virtual pascal void IEvtHandler(TEvtHandler *itsNextHandler);
- /* Sets up the reference to the next handler by setting the fNextHandler field to
- 'itsNextHandler', also sets the idle frequency and resets fLastIdle field to zero.
- */
-
- virtual pascal void Free(void);
- /* Before calling inherited Free, changes the target to the application if the next
- handler is NIL or the next handler if there is one. */
-
- /* Termination */
- virtual pascal void Terminate(void);
- /* Does nothing in this class. */
-
- /* Chainwalking */
- virtual pascal void EachHandler(pascal void (*DoToEvtHandler)(TEvtHandler *anEvtHandler, void *
- DoToEvtHandler_StaticLink), void *DoToEvtHandler_StaticLink);
-
- /* Performs 'DoToEvtHandler' to aFirstHandler, then to its fNextHandler, etc., onward
- until the fNextHandler chain ends at NIL */
-
- virtual pascal TEvtHandler *FirstHandlerThat(pascal Boolean (*TestEvtHandler)(TEvtHandler *
- anEvtHandler, void *TestEvtHandler_StaticLink), void *TestEvtHandler_StaticLink);
- /* Calls TestEvtHandler for each event handler until TestEvtHandler returns true.
- Returns the TEvtHandler object for which TestEvtHandler returned true, or NIL if
- TestEvtHandler never returned true. */
-
- virtual pascal TEvtHandler *AddHandler(TEvtHandler *headOfChain);
- /* Adds SELF from the chain of handlers starting at headOfChain. Returns the new
- head of chain. */
-
- virtual pascal TEvtHandler *RemoveHandler(TEvtHandler *headOfChain);
- /* Removes SELF from the chain of handlers starting at headOfChain. Returns the new
- head of chain (if self was the head then there _must_ be a new head. */
-
- /* Debugging */
- virtual pascal void IdentifySoftware(void);
- /* If fNextHandler is not NIL calls the next handler's IdentifySoftware method. */
-
- virtual pascal long LookupSymbol(StringPtr sym);
- /* Called by the debugger to translate a symbol into a number; default passes to the
- fNextHandler. sym will be uppercased. Return of -1 means symbol was not found. If
- sym = '?' then writeln a list of available symbols. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- /* Events */
- virtual pascal Boolean DoIdle(IdlePhase phase);
- /* Returns true if it frees itself so caller can know */
-
- virtual pascal Boolean DoHandleEvent(EventRecordPtr nextEvent, struct TCommand **
- commandToPerform);
- /* Handle the event and return TRUE if I want it, else I don't handle it, and return
- FALSE */
-
- /* Double/Triple Clicks */
- virtual pascal Boolean DoMultiClick(Point lastDownPt, Point newDownPt);
- /* Called by TApplication.CountClicks. Should return TRUE if the 2 points are close
- enough to be considered part of a double/triple click. (Both points are in global
- coordinates.) This is only called if the mouse down was within the proper time
- range of the previous mouse up. Default is to pass message to the nextEventHandler
- (if one exists), otherise to require that the sum of the x & y distances is <=
- gStdHysteresis. */
-
- /* Key Events */
- virtual pascal struct TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
- /* Handles all keystrokes except those with the command key held down. */
-
- virtual pascal struct TCommand *DoCommandKey(short ch, EventInfo *info);
- /* Handles command-key combinations only. */
-
- virtual pascal void KeyEventToComponents(EventInfo *info);
- /* Intended to extract character components of an event in a script manager
- compatible way. Default just forwards to next handler */
-
- /* MenuEvents */
- virtual pascal struct TCommand *DoMenuCommand(CmdNumber aCmdNumber);
- /* If the handler can perform the command it does so by either performing
- the command directly or by returning a TCommand. */
-
- virtual pascal void DoSetupMenus(void);
- /* Handles the setup of menus. */
-
- /* Help */
-
- virtual pascal struct TCommand *DoHelp(EventInfo *info, long *message);
- /* If fNextHandler is not NIL calls its DoHelp method, otherwise returns NIL. */
-
- /* View Creation from Templates*/
- virtual pascal struct TView *DoCreateViews(struct TDocument *itsDocument, struct TView *
- parentView, short itsRsrcID, VPoint *subViewOffset);
- /* This is the method responsible for creating view hierarchies from resource
- templates. If fNextHandler is not NIL it calls its DoCreateViews method. Otherwise
- it creates the desired view heirarchy. */
-
- virtual pascal struct TView *CreateAView(struct TDocument *itsDocument, struct TView *
- itsSuperView, Ptr *itsParams);
- /* For creating a single view from a resource template view. If fNextHandler is not
- NIL calls its CreateAView method, otherwise it proceeds to create the desired view.
- */
-
- /* Miscellaneous */
- virtual pascal Boolean HandlesPrintingCommands(void);
-
- /* If fNextHandler is not NIL calls its same method setting this method to the result,
-
- otherwise returns FALSE. */
-
- virtual pascal void InstallSelection(Boolean wasActive, Boolean beActive);
- /* The Target is told to do this after a window is activated or deactivated. */
-
- virtual pascal void SetIdleFreq(long newIdleFreq);
- /* Call to set the handler's idling frequency. */
-
- virtual pascal void DoChoice(struct TView *origView, short itsChoice);
- /* If its next handler is not NIL calls its DoChoice method.
- ??? should change the origView parameter to origHandler in a future version? */
-
- /* Command Management */
- virtual pascal void CommitLastCommand(void);
- /* Commits the last command by calling its Commit method.
- Default is to hand off to fNextHandler */
-
- virtual pascal struct TCommand *GetLastCommand(void);
- /* Returns the last undoable command. The command returned is not yet committed.
- Default is to hand off to fNextHandler */
-
- virtual pascal struct TCommand *GetNextCommand(void);
- /* Returns a previously posted command. Nil if there are no queued commands.
- Default is to hand off to fNextHandler */
-
- virtual pascal void PerformCommand(struct TCommand *command);
- /* Called to perform the given command.
- Default is to hand off to fNextHandler */
-
- virtual pascal void PostCommand(struct TCommand *command);
- /* Called to post a command to a queue for later execution.
- Default is to hand off to fNextHandler */
-
- };
-
- class TApplication : public TEvtHandler {
- public: /* The purpose of TApplication is to
- implement the main event loop that all
- Macintosh applications must have. There is
- only one instance of TApplication. One
- thing that TApplication does is to
- interpret the raw events that are posted
- and convert them into higher-level events.
- For example, it converts a click in the
- menu bar into a 'menu event' that contains
- the menu ID/item number that was chosen by
- the user. */
-
- /* There are not many TApplication variables--they are mostly global variables, for now…
- */
-
- long fTicksTilNextIdle; /* Formerly gIdleFreq. Computed number of
- ticks until the next time
- TApplication.Idle needs to be called to
- dole out idle time. Also is the maximum
- waitTicks that we can hand off to
- GetEvent. */
-
- long fTicksOfLastIdle; /* Formerly gLastIdle. Time in ticks of the
- last time the active chain and cohandlers
- were idled. */
-
- struct TCommandList *fCommandQueue;
- /* Commands that were posted for execution */
- Boolean fLaunchWithNewDocument; /* TRUE (the default) to create a new
- untitled document when the application is
- launched without a document. */
- struct TCommand *fLastCommand; /* the last command done or undone by the
- user */
-
- /* Init & Free */
- virtual pascal void IApplication(OSType itsMainFileType);
- /* itsMainFileType should be the the 4-byte file type that this application
- reads/writes. We require this here so that programmers do not have to explicitly
- override TApplication.SFGetParms and supply the type there. That is the only place
- where the main file type is used. */
-
- virtual pascal void GetInspectorName(StringPtr inspectorName);
- /* Used to get this class's name by the Inspector. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields, in this case the global variables. */
-
- /* Event Handling */
- virtual pascal Boolean GetEvent(short eventMask, long sleep, RgnHandle cursorRgn, EventRecord *
- anEvent);
-
- /* Calls WaitNextEvent (or GetNextEvent) with the given event mask, sleep, and cursor
- region parameters. You can override this if you have an alternate source for
- events. */
-
- virtual pascal struct TCommand *HandleAlienEvent(EventInfo *theEventInfo);
- /* This method is called upon to deal with 'application-specific' events */
-
- virtual pascal void MainEventLoop(void);
- /* Loop on PollEvent until the application is done */
-
- virtual pascal void DispatchEvent(EventInfo *theEventInfo, struct TCommand **commandToPerform);
-
- virtual pascal void HandleEvent(EventRecord *theEvent);
- /* When this is called by MacApp, theEvent is a pointer to the global variable
- gLastEvent. In special circumstances, you might 'fake' an event record and pass a
- pointer to it. */
-
- virtual pascal void PostHandleEvent(EventInfo *theEventInfo);
-
- virtual pascal struct TCommand *HandleActivateEvent(EventInfo *theEventInfo);
- /* Handles activate (and deactivate) events. Calls the window's Activate method, and
- sets gRedrawMenuBar to true if activating the window. Returns NIL. */
-
- virtual pascal struct TCommand *HandleDiskEvent(EventInfo *theEventInfo);
-
- /* Handles disk events. Calls DIBadMount if the high word of theEvent's message is <>
- noErr. Returns NIL. */
-
- virtual pascal void KeyEventToComponents(EventInfo *info);
- /* re-extracts components of an event in a script manager compatible way. */
-
- virtual pascal struct TCommand *HandleKeyDownEvent(EventInfo *theEventInfo);
- /* Handles key down events. If the command key is down, then this calls CommandKey.
- Otherwise it calls gTarget.DoKeyCommand. Returns the result of CommandKey or
- DoKeyCommand. */
-
- virtual pascal struct TCommand *HandleMouseDown(EventInfo *theEventInfo);
- /* Called when a mouse down occurs; this cases on whereMouseDown and does the right
- thing. */
-
- virtual pascal struct TCommand *TrackMouse(Point globalMouse, Point hysteresis, struct TCommand
- *theCommand);
-
- /* Responsible for mouse tracking. */
-
- virtual pascal struct TCommand *HandleMouseUp(EventInfo *theEventInfo);
- /* Sets gLastUpTime. Returns NIL. */
-
- virtual pascal struct TCommand *HandleSystemEvent(EventInfo *theEventInfo);
- /* Handles "system" events, in particular suspend/resume events and mouse moved
- events. Calls RegainControl if switching in, AboutToLoseControl if switching out,
-
- or TrackCursor if it is a mouse-moved event. Returns NIL. */
-
- virtual pascal struct TCommand *HandleUpdateEvent(EventInfo *theEventInfo);
- /* Handles window update events. Calls UpdateEvent for the window indicate by the
- event, and returns NIL. */
-
- virtual pascal Boolean IsDeskAccessory(GrafPtr aWMgrWindow);
-
- /* Returns true if the given Window Manager window is a desk accessory. We assume that
- if the window has a negative windowKind then it is a desk accessory. */
-
- virtual pascal void OpenDeskAccessory(StringPtr deskAccName);
- /* Attempts to open the desk accessory whose name is deskAccName. Called from
- TApplication.MenuEvent when an Apple menu item is chosen, and the item has a
- negative command number. */
-
- virtual pascal void PollEvent(Boolean allowApplicationToSleep);
- /* Polls for events calling Idle before waitNextEvent if there are no events pending
- and the application is allowed to go to sleep (kAllowApplicationToSleep),
-
- calls HandleEvent with the event, if there is one. and then idles if necessary. */
-
- virtual pascal void Run(void);
- /* HandleFinderRequest, and if not finder printing, call MainEventLoop */
-
- virtual pascal void UpdateAllWindows(void);
- /* Process all update events in the queue. */
-
- virtual pascal Boolean InModalState(void);
- /* Returns true if the front window is modal. */
-
- virtual pascal Boolean InModalMenuState(void);
- /* Returns true if the front window does not allow menu commands. */
-
- virtual pascal void ReportEvent(EventRecord *theEvent);
- /* Displays information about an event to the debugging window. */
-
- /* Target and Cohandlers */
- virtual pascal void InstallCohandler(TEvtHandler *aCohandler, Boolean addIt);
-
- /* Used to add (addIt = TRUE) or delete (addIt = FALSE) a cohandler to/from the global
- list of cohandlers */
-
- virtual pascal struct TWindow *GetFrontWindow(void);
- /* Returns the window object reference for the frontmost application window (whether
- active or not. Returns nil if the FrontWindow window is not a window object */
-
- virtual pascal struct TWindow *GetActiveWindow(void);
-
- /* Returns the window object reference for the active application window. Returns nil
- if the FrontWindow window is not a window object */
-
- virtual pascal void SetTarget(TEvtHandler *newTarget);
- /* Sets the current target (the head of the target chain) for the application. */
-
- /* Finder Requests */
- virtual pascal Boolean CanOpenDocument(CmdNumber itsCmdNumber, AppFile *anAppFile);
-
- /* Simulates the filtering done by Std File; this is only called when opening/printing
- documents from the finder; when using Std File, Std File does the filtering. */
-
- virtual pascal void HandleFinderRequest(void);
-
- /* Gets the info from the finder about what files to open/print and opens/prints them.
- */
-
- /* Opening / Printing Documents */
- virtual pascal struct TDocument *AlreadyOpen(StringPtr fileName, short volRefnum);
-
- /* Given a name/volRefnum, if that document is already opened, returns the TDocument.
- Otherwise returns NIL. */
-
- virtual pascal Boolean ChooseDocument(CmdNumber itsCmdNumber, AppFile *anAppFile);
- /* Call this to make a Std File Get call; returns TRUE is user selected a file. */
-
- virtual pascal struct TDocument *DoMakeDocument(CmdNumber itsCmdNumber);
- /* Must be overridden. Based on itsCmdNumber create a document object of the
- appropriate kind. */
-
- virtual pascal CmdNumber KindOfDocument(CmdNumber itsCmdNumber, AppFilePtr itsAppFilePtr);
- /* Given a cmd number and a specification of the file, return the cmd number to pass
- to DoMakeDocument that indicates the type of document to make; Default is to return
- itsCmdNumber. If you have multiple document types, a good convention is to return
- the cmd numbers assigned to create new documents of each kind. itsAppFilePtr will be
- NIL if we are creating a brand new document, rather than opening an existing
- document. */
-
- virtual pascal void OpenNew(CmdNumber itsCmdNumber);
- /* Called when the application is opened (itsCmdNumber = cFinderNew), or when NEW is
- chosen from menu (itsCmdNumber = cNew). If you do not want to create a new document
- when the user opens the application, override this and do nothing if itsCmdNumber =
- cFinderNew. */
-
- virtual pascal void OpenOld(CmdNumber itsOpenCmd, AppFile *anAppFile);
- /* Called when opening an existing document from finder (itsCmdNumber = cFinderOpen)
- or if OPEN is chosen from menu (itsCmdNumber = cOpen). */
-
- virtual pascal Boolean PrintDocument(AppFile *anAppFile);
-
- /* Called to print a document from the finder. Returns TRUE if the user did not cancel
- printing of the rest of the documents. */
-
- virtual pascal void SFGetParms(CmdNumber itsCmdNumber, short *dlgID, Point *where, Ptr *
- fileFilter, Ptr *dlgHook, Ptr *filterProc, TypeListHandle typeList);
- /* Called to return all the parameters that should be passed to SFGetFile; when
- called, typeList is a valid handle to a 0-length block. Defaults to
- dlgID = getDlgID;
- where = (100, 100);
- fileFilter = NIL;
- dlgHook = NIL;
- filterProc = NIL;
- typeList = list of just the main file type supported by the application. (If type
- list ends up with nothing in it, then all file types are supported. */
-
- /* Termination */
- virtual pascal void Close(void);
- /* Called when the user chooses Quit from the menu, and tries to save all the open
- documents. If all succeed the application terminates. Signals Failure with error =
- noErr and message = msgCancelled if user cancels */
-
- /* Hierarchy */
- virtual pascal void AddDocument(struct TDocument *aNewDocument);
- /* Add another document to my list of documents, and make it the current one */
-
- virtual pascal void AddFreeWindow(struct TWindow *aWindow);
- /* Add the window to the free-window list */
-
- virtual pascal void DeleteDocument(struct TDocument *docToDelete);
- /* Delete a document from my list of documents */
-
- virtual pascal void DeleteFreeWindow(struct TWindow *windowToDelete);
- /* Delete a window from my list of free windows */
-
- virtual pascal void EachFreeWindow(pascal void (*DoToWindow)(struct TWindow *aWindow, void *
- DoToWindow_StaticLink), void *DoToWindow_StaticLink);
- /* Perform DoToWindow on each TWindow object in the list gFreeWindowList */
-
- virtual pascal void ForAllDocumentsDo(pascal void (*DoToDoc)(struct TDocument *aDocument, void *
- DoToDoc_StaticLink), void *DoToDoc_StaticLink);
- /* Perform the given procedure on all open documents currently owned by the
- application */
-
- virtual pascal void ForAllWindowsDo(pascal void (*DoToWind)(struct TWindow *aWindow, void *
- DoToWind_StaticLink), void *DoToWind_StaticLink);
- /* Perform the given procedure on all windows known to the application, both
- document and free windows. */
-
- /* Window Manager Windows */
- virtual pascal void SelectWMgrWindow(GrafPtr aWMgrWindow);
-
- /* "Selects" aWMgrWindow by calling the toolbox routine SelectWindow. When any window
- is selected, it goes through here. We never call SelectWindow directly.*/
-
- virtual pascal GrafPtr GetRsrcWindow(Ptr storage, short rsrcId, Boolean *isResizable, Boolean *
- isClosable);
-
- /* Get a Window Manger window resource whose resource id is rsrId. Return isResizable
- and isClosable based upon the 'WIND' resource. */
-
- virtual pascal struct TWindow *WMgrToWindow(GrafPtr aWMgrWindow);
- /* Returns the window object that represents the given Window Manager window, or NIL
- if there is no window object. */
-
- /* Idle Events */
- virtual pascal void Idle(IdlePhase phase);
- /* Parcels out idle time to the DoIdle method in the target and cohandler chains of
- TEvtHandlers. If your application needs to do something at idle time then override
- DoIdle instead of this method. */
-
- /* Cursor */
- virtual pascal Boolean TrackCursor(void);
- /* Returns true if the cursor is set by a view. Otherwise the cursor is set to an
- arrow and TrackCursor returns false.*/
-
- /* Keyboard events */
- virtual pascal struct TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
- /* Handle keydown events. */
-
- /* Menu Events */
- virtual pascal struct TCommand *DoCommandKey(short ch, EventInfo *info);
- /* Called when a keyDown event is received and the command key is down. */
-
- virtual pascal struct TCommand *MenuEvent(long menuItem);
-
- /* Given a value returned by MenuKey or MenuSelect, figure out the command number that
- was chosen, have the application create a command object, and return it. */
-
- virtual pascal void SetUndoText(Boolean cmdDone, CmdNumber aCmdNumber);
-
- /* Called to setup the Undo menu item; if cmdDone is TRUE it reads Undo, otherwise it
- reads Redo. aCmdNumber indicates the command that goes after the Undo/Redo. */
-
- virtual pascal void SetupTheMenus(void);
- /* Initiates the process of enabling & checking menu items. */
-
- /* Opening and Closing Windows */
- virtual pascal void CloseWMgrWindow(GrafPtr aWMgrWindow);
- /* Called when user closes a window either with a menu item or with a GoAway box.
- Signals Failure with error = noErr and message = msgCancelled if user cancels */
-
- /* Command Management */
- virtual pascal void CommitLastCommand(void);
- /* Commits the last command by calling its Commit method. */
-
- virtual pascal struct TCommand *GetLastCommand(void);
- /* Returns the last undoable command. The command returned is not yet committed.*/
-
- virtual pascal struct TCommand *GetNextCommand(void);
- /* Returns a previously posted command. Nil if there are no queued commands.*/
-
- virtual pascal void PerformCommand(struct TCommand *command);
-
- /* Performs the given command taking care of UNDO/REDO and clipboard related details.
- Tracks the command first, if necessary.
- This DOES NOT check to see if command is NIL. */
-
- virtual pascal void PostCommand(struct TCommand *command);
- /* Called to post a command to the queue for later execution. */
-
- /* Double/Triple Clicks */
- virtual pascal short CountClicks(EventRecordPtr aPDownEvent, short whereMouseDown);
- /* Called by TApplication.HandleMouseDown. Returns the number of clicks that can be
- considered multiple clicks (e.g. if it returns 1 the mouse down should be treated
- as a single click, or possibly the first click of a multi-click sequence. If it
- returns 2 the click should be considered a double-click, etc. A click is considered
- part of a multi-click sequence if the mouse down was within the proper time range
- of the previous mouse up, and was within the proper number of pixels of the last
- mouse down. TApplication.HandleMouseDown sets theClickCount of its EventInfo record
- to the result of this function. aPDownEvent is a pointer to the mouse down event.
- whereMouseDown is the result of FindWindow on the event. */
-
- /* Command Handlers */
- virtual pascal struct TCommand *DoMenuCommand(CmdNumber aCmdNumber);
- /* Handles the application specific menu commands. */
-
- virtual pascal void DoSetupMenus(void);
-
- /* Clipboard stuff */
-
- virtual pascal void AbandonUndoClipboard(void);
- /* Called when the undo clipboard is no longer needed. Calls
- gClipUndoView.FreeFromClipboard and sets gClipUndoView to NIL. */
-
- virtual pascal void AboutToLoseControl(Boolean convertClipboard);
-
- /* Called when about to activate a Desk Accessory, switch out to another application,
-
- or Terminate. convertClipboard is generally true, except it will be FALSE if we get
- a Swticher event that does not require Clipboard conversion */
-
- virtual pascal void AbsorbScrapStuff(void);
-
- /* Called to retrieve the current InfoScrap record from low memory. This will be used
- to determine if the scrap has changed. */
-
- virtual pascal void CheckDeskScrap(void);
- /* Checks to see if the desk scrap has changed by calling AbsorbScrapStuff and
- comparing the current scrap change count with the previous change count. If the
- scrap has changed, then the current clipboard becomes the undo clipboard and
- ReadFromDeskScrap is called to read in the new desk scrap. */
-
- virtual pascal void ClaimClipboard(struct TView *clipView);
- /* Makes clipView the new view displayed by the Clipboard. Typically called by a Cut
- or Copy command. */
-
- virtual pascal long GetDataToPaste(Handle aDataHandle, ResType *dataType);
- /* Returns the number of bytes in the paste data. Will signal Failure if it gets an
- error. */
-
- virtual pascal void LaunchClipboard(void);
- /* Called by TApplication.Run, before the main event loop. */
-
- virtual pascal struct TWindow *MakeClipboardWindow(void);
- /* Called by TApplication.IApplication to make the clipboard window and associated
- frame(s). clipView is the view to be initially installed in the clipboard--it is
- gClipOrphanage. */
-
- virtual pascal void ReadFromDeskScrap(void);
- /* Called at launch and when the desk scrap changes. Calls
- TApplication.MakeViewForAlienClipboard, then ClaimClipboard */
-
- virtual pascal struct TView *MakeViewForAlienClipboard(void);
-
- /* Returns gClipOrphanage, which is capable of displaying scrap of type TEXT or PICT.
- Override this to create a view to handle other types of scrap data. */
-
- virtual pascal void RegainControl(Boolean checkClipboard);
- /* Called when switching in or when leaving a desk accessory */
-
- virtual pascal void SetClipView(struct TView *clipView);
- /* Installs the given view into the clipboard window. */
-
- virtual pascal void SwapClipViews(void);
-
- /* Swaps the undo clipboard view with the current clipboard view. Used during an Undo
- or Redo. */
-
- /* Debugging */
- virtual pascal void IdentifySoftware(void);
-
- /* Writes out to the debug window the current version of MacApp® , UObject and UDebug.
- */
-
- /* Error Alerts */
-
- virtual pascal void Beep(short duration);
-
- /* Call this method when you want to beep at the user. Sound manager users may have to
- override this method to integrate its functionality in with your application */
-
- virtual pascal void ShowError(OSErr error, long message);
- /* Calls ErrorAlert to display an error alert. */
-
- virtual pascal void SpaceIsLow(void);
- /* Called when space is low, at intervals of kLowSpaceInterval ticks. Displays an
- alerting informing the user that memory space is low. Override this if you wish to
- take more appropriate action. */
-
- /* Miscellaneous */
-
- virtual pascal void DoShowAboutApp(void);
- /* Called to show the "About the App" information */
-
- virtual pascal void InvalidateFocus(void);
- /* Called to indicate that a view is unfocused when you don't know which view
- was focused. */
-
- virtual pascal void InvalidateCursorRgn(void);
- /* Indicates that the cursor rgn that is used to determine when MultiFinder™ should
- wake up your application and tell you the mouse moved is invalid and must be
- recomputed. When not using MultiFinder™ the region is used to determine when to
- give all the subviews a chance to set the cursor. */
-
- virtual pascal void ActivateBusyCursor(Boolean entering);
- /* Called when the busy cursor mechanism should be activated or deactivated. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TDocument : public TEvtHandler {
- public: /* Corresponds to a Finder document. Manages
- document data in files and in main memory.
- */
- TList *fWindowList;
- /* list of windows belonging to this document
- */
- TList *fViewList; /* list of views belonging to document */
- struct TPrintHandler *fDocPrintHandler; /* the object to be told to PRINT or
- DoSetUpMenus when 'Print', 'Print One', or
- 'Page Setup…' is selected from the menu
- while this is the active document. */
-
- long fChangeCount;
- /* master count of changes since last Save */
- Boolean fSavePrintInfo; /* if TRUE for a document saved on disk, the
- 'print info' record of the
- fDocPrintHandler will be written out to
- the data fork before other writing takes
- place */
- Boolean fSharePrintInfo;
- /* if TRUE, then all printHandlers associated
- with views belonging to the same document
- will share the same 'print info' record */
- Handle fPrintInfo;
- /* if non-NIL, this is a handle to a 120-byte
- 'print info' record */
-
- StringHandle fTitle; /* file name */
- OSType fFileType; /* file type */
- OSType fCreator; /* creator ID */
- short fVolRefNum; /* volume refNum */
- long fModDate; /* file mod date when last read/saved */
- Boolean fReopenAlert; /* whether to give an alert if user reopens
- doc */
- Boolean fSaveExists; /* whether a disk file representing this
- document exists */
- Boolean fCommitOnSave; /* commit the last command before saving the
- document, if it affected the document.
- This defaults to TRUE, but carefully
- written applications could set this FALSE.
- */
- Boolean fUsesDataFork;
- /* whether the document uses the data fork of
- the file */
- Boolean fUsesRsrcFork;
- /* whether the document uses the rsrc fork of
- the file */
- Boolean fDataOpen; /* whether the data fork should be open all
- the time */
- Boolean fRsrcOpen;
- /* whether the resources fork be open all the
- time */
- short fDataPerm;
- /* permission to use for reading data fork */
- short fRsrcPerm; /* permission to use for reading the rsrc
- fork */
- short fDataRefnum; /* refnum; valid only if data fork is left
- open */
- short fRsrcRefnum; /* refnum; valid only if resource fork is
- left open */
- /* these will be -1 if the fork is
- not open or if the corresponding
- fXXXOpen flag is FALSE */
- SIPChoice fSaveInPlace;
- /* how to save files in place (if desired) */
-
- /* Init & Free */
- virtual pascal void IDocument(OSType itsFileType, OSType itsCreator, Boolean usesDataFork,
- Boolean usesRsrcFork, Boolean keepsDataOpen, Boolean keepsRsrcOpen);
- /* Initialization method for TDocument. */
-
- virtual pascal void Free(void);
-
- /* This does not call FreeData by default, since you may need to control the order in
- which things are freed. Your override of TDocument.Free can call FreeData if
- convenient. */
-
- virtual pascal void FreeData(void);
- /* Called when a document is reverted, in order to free it's data objects. You may
- also wish to call this from you document's Free method, if convenient. */
-
- virtual pascal void FreeFromClipboard(void);
- /* Called to free a Clipboard document.Simply calls Free. */
-
- virtual pascal void GetInspectorName(StringPtr inspectorName);
- /* Called by the Inspector to get the name of this class. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Called by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- /* Opening / Printing Documents */
- virtual pascal void DoInitialState(void);
- /* Called for 'New', 'Revert' to blank, Open Tool. Default is to do nothing; You may
- need to do further initialization that you would not do in case of an Open… */
-
- virtual pascal void DoMakeWindows(void);
- /* Should take the views created by DoMakeViews and create windows and frames to
- display them. */
-
- virtual pascal void DoMakeViews(Boolean forPrinting);
-
- /* Create all necessary views for this document (based on forPrinting flag) and store
- into fields of your document. The document will then be sent either DoMakeWindows
- or Print. */
-
- virtual pascal void DoRead(short aRefNum, Boolean rsrcExists, Boolean forPrinting);
-
- /* rsrcExists indicates whether the document has a resource fork opened or not; it is
- FALSE if fUsesRsrcFork is FALSE. makingCopy indicates whether this save is for
- making a copy of the document (vs. a regular Save or Save As…); disk-based
- documents (especially) might optimize their behavior if this is TRUE. The default
- behaviour is to just read the printinfo from the document's data-fork (useful huh?)
- */
-
- virtual pascal void DoWrite(short aRefNum, Boolean makingCopy);
-
- /* rsrcExists indicates whether the document has a resource fork opened or not; it is
- FALSE if fUsesRsrcFork is FALSE. makingCopy indicates whether this save is for
- making a copy of the document (vs. a regular Save or Save As…); disk-based
- documents (especially) might optimize their behavior if this is TRUE. The default
- behaviour is to just write the printinfo to the document's data-fork (useful huh?)*/
-
- virtual pascal Boolean HandlesPrintingCommands(void);
- /* By defualt returns FALSE. */
-
- virtual pascal OSErr OpenAFile(StringPtr name, short volRefnum, Boolean openData, Boolean
- openRsrc, short dataPerm, short rsrcPerm, short *dataRefnum, short *rsrcRefnum);
- /* Called from ReadFromFile to open the document's data and/or resource forks.*/
-
- virtual pascal void OpenAgain(CmdNumber itsCmdNumber, TDocument *openingDoc);
- /* Called if the user tries to open the same document twice. openingDoc will be the
- document object being opened. Default brings SELF to the front and calls
- Failure(noErr, 0), which will abort opening the document. (The goal is to prevent
- the user from having 2 copies of the same document open, in which case they could
- make incompatible changes to both.) You might override this if you want to open a
- second window on the same document. In the ideal case, you should make both windows
- display exactly the same data, and changes made to one should be reflected in the
- other. You could also override this to create a read-only copy of the document. */
-
- virtual pascal void ReadFromFile(AppFile *anAppFile, Boolean forPrinting);
- /* Called to read an existing file for display or printing. If anAppFile.fName = ''
- THEN we read from the file specified in the instance variables instead of the
- parameter, and the parameter will be updated to match the document. */
-
- virtual pascal void ShowWindows(void);
- /* Called when opening the document initially; default is to call OpenWindow for all
- windows that have fFlags.openInitially TRUE */
-
- virtual pascal void UntitledName(StringPtr noName);
- /* Called to supply a name for an untitled document. If this returns '' then the
- windows are not renamed from the value specified in their titles. */
-
- /* Saving Documents */
- virtual pascal void AboutToSave(CmdNumber itsCmd, StringPtr newName, short *newVolRefnum,
- Boolean *makingCopy);
-
- /* Called right after the SFPutFile (if any) and before deciding between SaveViaTemp &
- SaveInPlave. Applications can use the name in an alert and/or modify the makingCopy
- parameter if they do not want to have the document renamed. */
-
- virtual pascal void DoNeedDiskSpace(long *dataForkBytes, long *rsrcForkBytes);
-
- /* Bytes required to store SAVE file(s) on disk. When called, both parameters are set
- to 0 for you. */
-
- virtual pascal void FreeFile(void);
- /* Called to free in memory data associated with the currently opened document. The
- default is to call CloseFile(fDataRefnum, fRsrcRefnum) if fDataOpen OR fRsrcOpen. */
-
- virtual pascal Boolean GetSaveInfo(CmdNumber itsCmdNumber, Boolean copyFInfo, CInfoPBRec *cInfo)
- ;
- /* Called to get the desired file info for saving the file. Default copies the info
- from the current file if fSaveExists AND copyFInfo, otherwise it just sets the file
- type and creator based on the fields of SELF. If an error occurs calling the file
- system, the cInfo record will not be filled in. Returns TRUE if it successfully
- gets the info from the file. */
-
- virtual pascal void GetTempName(StringPtr fileName);
- /* Return a temporary name for saving the file. The filename is constructed in two
- parts: the first part is the document's name, or the application's name if the
- document is untitled. The second part, appended to the first part, is a pseudo-
- random number based on the tick count and number of seconds since boot. */
-
- virtual pascal void MakeNewCopy(Boolean makingCopy, Boolean validFInfo, CInfoPBRec *cInfo);
-
- /* Creates a brand new copy of the document in the file specified by cInfo. The name,
-
- volume refnum, file type, and creator must be specified in cInfo. The other info
- fields of cInfo are used only if makingCopy is FALSE. makingCopy is TRUE if this
- save is making a copy of the document (vs. a regular Save or Save As…) Caller is
- responsible for calling FlushVol after this. */
-
- virtual pascal short PoseSaveDialog(void);
-
- /* If the document has been changed (fChangeCount > 0), then the user is asked to save
- the document. PoseSaveDialog returns cancel, kYesButton or kNoButton, depending on
- the button chosen by the user. If the document has not been changed then kNoButton
- is returned. */
-
- virtual pascal void RequestFileName(CmdNumber itsCmdNumber, Boolean makingCopy, StringPtr
- fileName, short *volRefnum);
-
- /* Asks the user for a filename for the document. Calls TDocument.SFPutParms and then
- SFPPutFile. Fails if the user clicks the Cancel button to end the put file dialog.
- */
-
- virtual pascal long GetChangeCount(void);
- /* Gets the document change count */
-
- virtual pascal void SetChangeCount(long newChangeCount);
- /* Sets the document change count */
-
- virtual pascal void Save(CmdNumber itsCmdNumber, Boolean askForFilename, Boolean makingCopy);
- /* Try to save the document to disk; If askForFilename, put up a Std File box; If
- makingCopy, then this is for the Save a Copy In command, so we do not rename the
- document. This method calls FlushVol (which takes care of the requirements of
- MakeNewCopy, SaveInPlace, and SaveViaTemp. */
-
- virtual pascal void SaveAgain(CmdNumber itsCmdNumber, Boolean makingCopy, TDocument *savingDoc);
-
- /* Called when the user tries to Save As… or Save a Copy In… and specifies the name of
- a document that is already opened. The default case calls Failure(errSaveAgain,
-
- msgSaveFailed) to display an error. (The goal is to prevent the user from having 2
- copies of the same document open, in which case they might make incompatible
- changes to both copies.) savingDoc is the document being saved */
-
- virtual pascal void SavedOn(StringPtr fileName, short volRefnum);
- /* Called when a save successfully completes and we are switching to the new file
- (ie., not a Save a Copy In…). */
-
- virtual pascal void SaveInPlace(CmdNumber itsCmdNumber, Boolean makingCopy, Boolean copyFInfo,
- StringPtr fileName, short volRefnum);
- /* Called to save a document in place. Default is to delete the existing file if NOT
- (fDataOpen OR fRsrcOpen). If you have disk based document, you have to decide
- whether to allow saving in place. makingCopy is TRUE if this save is making a copy
- of the document (vs. a regular Save or Save As…) copyFInfo is TRUE if the file
- information should be copied to the new file Caller is responsible for calling
- FlushVol after this. */
-
- virtual pascal void SaveViaTemp(CmdNumber itsCmdNumber, Boolean makingCopy, Boolean copyFInfo,
- StringPtr fileName, short volRefnum);
- /* Called to save the document by creating a temporary copy of the file and renaming
- it. MacApp uses this method except when there is not enough disk space available.
- makingCopy is TRUE if this save is making a copy of the document (vs. a regular
- Save or Save As…) copyFInfo is TRUE if the file information should be copied to the
- new file Caller is responsible for calling FlushVol after this. */
-
- virtual pascal void SFPutParms(CmdNumber itsCmdNumber, short *dlgID, Point *where, StringPtr
- defaultName, StringPtr prompt, Ptr *dlgHook, Ptr *filterProc);
- /* Called to return all the parameters that should be passed to
- SFPutFile. Defaults to
- dlgID = putDlgID;
- where = (100, 100);
- defaultName not changed;
- prompt gotten from resource file;
- dlgHook = NIL;
- filterProc = NIL. */
-
- /* Closing Documents */
- virtual pascal void Close(void);
- /* Close a document and free it. Signals Failure with error = noErr and message =
- msgCancelled if user cancels. ??? NOTE: Must never be called for a document related
- to a view in the Clipboard. */
-
- /* Revert */
- virtual pascal void Revert(void);
- /* IF fSaveExists is TRUE then reverts to the file saved on disk, otherwise merely
- resets the print handler and calls doInitialState. Calls FreeData to free any
- existing data and commits any currently active command. */
-
- virtual pascal void Abandon(void);
-
- /* Called when a document is closed and changes are being abandoned. For memory based
- documents the default behaviour of doing nothing is OK. For disk based
- documents that
- change the original copy this is the place to override to put back the original
- contents if you still have it available somewhere (a scratch file?) */
-
- virtual pascal void ShowReverted(void);
- /* Called after Revert to show brand new document; default tells each view to
- ShowReverted */
-
- /* Miscellaneous */
- virtual pascal void CheckDiskFile(short rsrcId, short rsrcIndex, Boolean reverting);
- /* Check to see if the disk file has changed. If so put up alert phFileChanged after
- setting ^0 to fTitle and ^1 to the string specified by the rsrcId and rsrcIndex. If
- user cancels, signal Failure(noErr, msgCancelled). If reverting is TRUE,
- then I/O
- errors and nonmatching file types will cause a Failure. Otherwise, this is a Save
- and any I/O errors and nonmatching file type will be ignored. */
-
- virtual pascal OSErr DiskFileChanged(Boolean checkType);
- /* Returns noErr if fSaveExists is FALSE or if the file's modification date matches
- fModDate. If checkType is TRUE then returns errFTypeChanged if the file type has
- changed. If the file exists but with a different modification date, returns
- errFileChanged. */
-
- virtual pascal void SetTitle(StringPtr aTitle);
- /* Sets SELF.fTitle to aTitle and calls SetTitleForDoc for each window of the
- document. */
-
- /* Command Handlers */
- virtual pascal struct TCommand *DoMenuCommand(CmdNumber aCmdNumber);
-
- /* Handles the default menu commands associated with a document and must be overridden
- to handle any additional items. */
-
- virtual pascal void DoSetupMenus(void);
- /* Setup the documents menus, this handles the default menus and must be overridden
- for any additional items. */
-
- /* Hierarchy */
- virtual pascal void AddView(struct TView *aView);
- /* Adds the view to the end of the document's view list. */
-
- virtual pascal void AddWindow(struct TWindow *aWindow);
- /* Adds the window to the end of the document's window list. */
-
- virtual pascal void CloseView(struct TView *aView);
- /* Called to close a view or window associated with a document.
- Document gets to decide whether to really close the view or not and whether to
- close itself or not. Does nothing if the view is not associated with the doc. */
-
- virtual pascal void DeleteView(struct TView *viewToDelete);
- /* Deletes the view from the document's view list. */
-
- virtual pascal void DeleteWindow(struct TWindow *windowToDelete);
- /* Deletes the window from the document's window list. */
-
- virtual pascal void ForAllViewsDo(pascal void (*DoToView)(struct TView *aView, void *
- DoToView_StaticLink), void *DoToView_StaticLink);
- /* Performs DoToView on every view in every window belonging to the document. If you
- want to deal with all views belonging to the document use fViewList.Each. */
-
- virtual pascal void ForAllWindowsDo(pascal void (*DoToWind)(struct TWindow *aWindow, void *
- DoToWind_StaticLink), void *DoToWind_StaticLink);
- /* Perform the supplied proc to each window belonging to the document */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- typedef enum {ViewType, ViewIncludeAt} ViewTemplateSelector; /* So C++ unions can have names */
- struct viewType {
- ResType itsParentID;
- ResType thisViewID;
- VPoint itsLocation;
- VPoint itsSize;
- SizeDeterminer itsVSizeDet : 3;
- SizeDeterminer itsHSizeDet : 3;
- unsigned isShown : 1;
- unsigned isEnabled : 1;
- Byte filler;
- ResType itsSignature;
- Str255 itsType;
- };
-
- struct viewIncludeAt {
- ResType itsParentID;
- ResType thisViewID;
- VPoint itsLocation;
- VPoint itsSize;
- SizeDeterminer itsVSizeDet : 3;
- SizeDeterminer itsHSizeDet : 3;
- unsigned isShown : 1;
- unsigned isEnabled : 1;
- Byte filler;
- ResType itsSignature;
- short includeRsrcID;
- VPoint itsSubViewOffset;
- };
- union ViewTemplate {
- viewType ViewType; /* Actually variable length */
- viewIncludeAt ViewIncludeAt;
- };
- typedef ViewTemplate *ViewTemplatePtr;
-
- struct ViewResource {
- short numViews;
- ViewTemplate theViews; /* Actually, open-ended */
- };
- typedef ViewResource *ViewRsrcPtr;
- typedef ViewRsrcPtr *ViewRsrcHandle; /* Preferred */
- typedef ViewRsrcHandle ViewRsrcHndl; /* Left in for compatibility (2.0) */
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- /* Set by GetFocus; used by SetFocus. GetFocus/SetFocus are used to save and restore the
- focus
- behind MacApp's back. One use is to speed up scrolling (see TScroller). */
- #if qExperimentalAndUnsupported
- struct FocusRec {
- Boolean printing;
- Boolean drawingPictScrap;
- struct TView *drawingPictScrapView;
- struct TView *focusedView;
- VPoint longOffset;
- Point org;
- GrafPtr port;
- RgnHandle clip;
- Boolean isValid; /* TRUE if FocusRec is valid */
- };
- #endif
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TView : public TEvtHandler {
- public: /* Renders an image of a document or other
- data, and identifies mouse-clicked
- objects. */
- TView *fSuperView; /* the current superview */
- TList *fSubViews; /* subviews of this view */
- TDocument *fDocument; /* the associated document if any. */
- VPoint fLocation; /* the location in superview coordinates */
- VPoint fSize; /* the size of this view */
- SizeDeterminer fSizeDeterminer[2];
- /* how this view's size is to
- be determined */
- HLState fHLDesired; /* the hilighting that is desired for this
- view */
- ResType fIdentifier; /* the ID if any */
- Boolean fShown; /* is this view to be shown */
- Boolean fViewEnabled; /* is this view enabled. (does it take
- clicks/keystrokes */
- struct TPrintHandler *fPrintHandler; /* the associated print handler if any. */
- #if qExperimentalAndUnsupported
- FocusRec fFocusRec; /* The cached focus information */
- #endif
-
- /* Creation/Destruction Methods */
-
- virtual pascal void IView(TDocument *itsDocument, TView *itsSuperView, VPoint *itsLocation,
- VPoint *itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet);
- /* Initializes a view procedurally. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize aview from a resource template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* For writing a view out to a resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
-
- /* For writing a view to a resource works in conjunction with tbe previous method. */
-
- virtual pascal void Free(void);
- /* Frees its subviews, then if its superview is not NIL removes itself from the
- superviews list of subviews and if its document is not NIL removes itself from the
- documents list of views. If it has a print handler then it frees it, then calls
- inherited Free. */
-
- virtual pascal void FreeFromClipboard(void);
- /* If its document is not NIL then calls the document's FreeFromClipboard method,
-
- otherwise calls Free. */
-
- /* Coordinate Conversion Methods */
-
- virtual pascal void QDToViewPt(Point qdPoint, VPoint *viewPt);
- /* Convert a Quickdraw point to a view point. */
-
- virtual pascal void QDToViewRect(Rect *qdRect, VRect *viewRect);
- /* Convert a Quickdraw rect to a view rect. */
-
- virtual pascal Point ViewToQDPt(VPoint *viewPt);
- /* Convert a view point to a QuickDraw point. */
-
- virtual pascal void ViewToQDRect(VRect *viewRect, Rect *qdRect);
- /* Convert a view rect to a Quickdraw rect. */
-
- virtual pascal void LocalToSuper(VPoint *thePoint);
-
- /* Given a point in local view coordinates, returns the same point in its superview's
- coordinate system.*/
-
- virtual pascal void SuperToLocal(VPoint *thePoint);
- /* Given a point in superview coordinates, returns the same point in the view's own
- coordinate system. */
-
- virtual pascal void LocalToWindow(VPoint *thePoint);
-
- /* Given a point in local view coordinates, returns the same point in its window's (or
- most super superview's) coordinate system.*/
-
- virtual pascal void WindowToLocal(VPoint *thePoint);
- /* Given a point in window (or most super superview) coordinates, returns the same
- point in the view's own coordinate system. */
-
- /* SubView Management Methods */
-
- virtual pascal void EachSubView(pascal void (*DoToSubView)(TView *theSubView, void *
- DoToSubView_StaticLink), void *DoToSubView_StaticLink);
- /* Iterate over all the views subviews passing each in turn to the procedure
- "DoToSubView". */
-
- virtual pascal TView *FirstSubViewThat(pascal Boolean (*TestSubView)(TView *theSubView, void *
- TestSubView_StaticLink), void *TestSubView_StaticLink);
- /* Iterate over this views subviews and return the first subview that meets
- 'TestSubView'. */
-
- virtual pascal TView *LastSubViewThat(pascal Boolean (*TestSubView)(TView *theSubView, void *
- TestSubView_StaticLink), void *TestSubView_StaticLink);
- /* Iterate over this views subviews and return the last subview that meets
- "TestSubView". */
-
- virtual pascal void AddSubView(TView *theSubView);
- /* Add 'theSubView' to our list of subviews. */
-
- virtual pascal void RemoveSubView(TView *theSubView);
- /* Remove 'theSubView' from our list of subviews. */
-
- virtual pascal void MakeFirstSubView(TView *theSubView);
- /* Make 'theSubView ' the first subview in our list. */
-
- virtual pascal void MakeLastSubView(TView *theSubView);
- /* Make 'theSubView' the last subview in our list. */
-
- virtual pascal short CountSubViews(void);
- /* Return the number of subviews in our view. */
-
- virtual pascal TView *FindSubView(ResType itsIdentifier);
- /* Find subview with identifier 'itsIdentifier' in our list of subviews. */
-
- /* Open/Close/Activate Methods */
-
- virtual pascal void Activate(Boolean entering);
- /* Focuses and then highlights any current selection before calling all its subviews
- to activate themselves. */
-
- virtual pascal void Open(void);
- /* Calls each of its subviews to Open themselves. */
-
- virtual pascal void Close(void);
-
- /* Commits the last command before calling each of its subviews to Close themselves. */
-
- virtual pascal void BeInScroller(struct TScroller *itsScroller);
- /* If 'itsScroller' is not NIL then sets its scroll limits to its fSize. */
-
- virtual pascal void BeInPort(GrafPtr itsPort);
- /* If its print handler is not NIL, calls DoCheckPrinter. Then calls each of its
- subviews to BeInPort. */
-
- virtual pascal void ShowReverted(void);
-
- /* First calls AdjustSize before forcing a redraw of the view, then call ShowReverted
- for each of its subviews. */
-
- /* Choice Handling Methods */
-
- virtual pascal void DoChoice(TView *origView, short itsChoice);
- /* If its superview is not NIL calls its DoChoice method. */
-
- /* Size Methods */
-
- virtual pascal void AdjustSize(void);
- /* Calls ComputeSize, if the size has changed resizes itself and then calls
- DoPagination so that any page breaks can be recalculated. */
-
- virtual pascal void CalcMinSize(VPoint *minSize);
- /* Calculate the minimum size of SELF. */
-
- virtual pascal void ComputeSize(VPoint *newSize);
- /* Called by MacApp® to get the size of the view computed. */
-
- virtual pascal void Resize(VCoordinate width, VCoordinate height, Boolean invalidate);
- /* Resizes SELF to 'width' & 'height', and forces an invalidation if 'invalidate' is
- TRUE. */
-
- virtual pascal void SuperViewChangedSize(VPoint *delta, Boolean invalidate);
- /* Called when our superview changes size. */
-
- virtual pascal void SubViewChangedSize(TView *theSubView, VPoint *delta);
- /* Called when one of our subviews changes size. */
-
- /* Location Methods */
-
- virtual pascal void Locate(VCoordinate h, VCoordinate v, Boolean invalidate);
- /* Moves our view to coordinate 'h' & 'v' invalidating if 'invalidate' is TRUE. */
-
- virtual pascal void SubViewMoved(TView *theSubView);
- /* Called when a subview is moved. */
-
- virtual pascal void SuperViewMoved(Boolean invalidate);
- /* Called when our superview is moved. */
-
- /* Focusing Methods */
-
- virtual pascal Boolean Focus(void);
- /* Attempts to set up the drawing environment for this view. That consists of port,
-
- origin, gLongOffset and clipping. Returns FALSE if not able to focus. One reason
- focus could fail is if no superview is able to supply a port (ie not in a window
- and not printing or drawing pict scrap). Focus will return true, however, if the
- drawing environment can be setup but none of the view is currently visible due to
- clipping or scrolling by a superview. This lets you assemble view hierarchies and
- manipulate views without showing them to the user, but requires that you test
- IsVisible if you MUST know if the view is in fact visible. (MacApp will never ask a
- view to draw unless it is visible) */
-
- virtual pascal Boolean FocusOnSuperView(void);
- /* Focuses on our superview. */
-
- virtual pascal void InvalidateFocus(void);
- /* Indicates that the view's focus is no longer valid and must be recomputed. */
-
- virtual pascal Boolean IsFocused(void);
- /* Check to see if we are currently focused. */
-
- virtual pascal void ClipFurtherTo(Rect *r, short hDeltaOrg, short vDeltaOrg);
-
- /* Set clipping to: (<current clipping> INTERSECT r) OFFSET-BY (hDeltaOrg, vDeltaOrg).
- */
-
- virtual pascal void AssumeFocused(void);
- /* Causes a ProgramBreak if the focused view isn't SELF */
-
- /* Drawing Methods */
-
- #if qExperimentalAndUnsupported
- virtual pascal void DoOffScreen(pascal void (*WhatToDo)(void *WhatToDo_StaticLink), void *
- WhatToDo_StaticLink);
- /* The WhatToDo procedure is performed while focused "offscreen" and the results
- are blitted back on to the screen. */
- #endif
-
- virtual pascal void DrawContents(void);
- /* Causes the views contents to be drawn and that of any of its subviews. */
-
- virtual pascal void Draw(Rect *area);
- /* Currently does nothing. Must be overridden. */
-
- virtual pascal void DoHighlightSelection(HLState fromHL, HLState toHL);
- /* Currently does nothing. Must be overridden. */
-
- virtual pascal void Adorn(Rect *area, Point itsPenSize, unsigned short itsAdornment);
- /* Handles the adornment of the view based on the CntlAdornment enumeration. */
-
- virtual pascal Boolean HasPendingUpdate(void);
- /* Returns TRUE if there is a pending update event for this view, FALSE if not. */
-
- virtual pascal void Update(void);
- /* If its window is not NIL then does an update by calling DrawContents. */
-
- /* Validation/Invalidation Methods */
-
- virtual pascal void ForceRedraw(void);
- /* Invalidates the entire view forcing a redraw. */
-
- virtual pascal void InvalidVRect(VRect *viewRect);
- /* Invalidates a view rect. */
-
- virtual pascal void ValidVRect(VRect *viewRect);
- /* Converts 'viewRect' to a QD Rect then calls VisibleRect & ValidRect with the result.
- */
-
- virtual pascal void InvalidRect(Rect *r);
- /* Invalidates a Quickdraw rect. */
-
- virtual pascal void RevealRect(VRect *rectToReveal, Point minToSee, Boolean redraw);
-
- /* Scrolls a rect in to view, with 'minToSee' being the point which will end up at the
- bottom of the view, i.e.the minimum amount to be seen and 'rectToReveal' the rect
- being scrolled. */
-
- virtual pascal void RevealTop(Boolean redraw);
- /* Scroll the top of a rect into view. */
-
- virtual pascal void RevealBottom(Boolean redraw);
- /* Scroll the bottom of a rect into view. */
-
- /* Mouse Handling Methods */
-
- virtual pascal Boolean ContainsMouse(VPoint *theMouse);
- /* Is the view point 'theMouse' currently in our view. */
-
- virtual pascal Boolean HandleMouseDown(VPoint *theMouse, EventInfo *info, Point *hysteresis,
- struct TCommand **theCommand);
-
- /* The method responsible for handling a mouse down in the view, calls DoMouseCommand
- to handle it. */
-
- virtual pascal struct TCommand *DoMouseCommand(Point *theMouse, EventInfo *info, Point *
- hysteresis);
-
- /* Returns a simple tracker which by default calls back tracking methods of this view.
- There are two possibilities here:
- 1) Override DoMouseCommand to return commands that represent more complex, even
- undoable actions. That command may either let its tracking call back the view's
- tracking methods (the default) which must be overridden to do anything useful or it
- may simply do all the tracking itself. This mostly depends on whether different
- commands returned from the view would have different tracking behavior. For example
- this is the approach taken by DrawShapes.
- 2) Override the view's tracking methods and let the default tracker them
- . For example
- this is the approach taken by TControl. */
-
- /* Cursor Handling Methods */
-
- virtual pascal TView *HandleCursor(VPoint *theMouse, RgnHandle cursorRgn);
- /* Handles the setting of the cursor by calling our DoSetCursor method and the same
- For all our subviews. */
-
- virtual pascal Boolean DoSetCursor(Point localPoint, RgnHandle cursorRgn);
-
- virtual pascal void GetDefaultCursorRgn(Point localPoint, RgnHandle cursorRgn);
- /* Returns the largest appropriate cursor region, called by DoSetCursor. */
-
- /* Miscellaneous Methods */
-
- virtual pascal TView *GetDialogView(void); /* actually, TDialogView… */
- /* If our superview is not NIL then calls its GetDialogView method and returns the
- result, otherwise returns NIL. */
-
- virtual pascal GrafPtr GetGrafPort(void);
- /* Returns a pointer to our Graf Port. */
-
- virtual pascal struct TScroller *GetScroller(Boolean immediateSuperView);
- /* Returns a reference to our scroller. */
-
- virtual pascal struct TWindow *GetWindow(void);
- /* Returns a reference to the window that we are in, if any. */
-
- virtual pascal void GetExtent(VRect *itsExtent);
- /* Returns a view rect the size of our extent in 'itsExtent'. */
-
- virtual pascal void GetQDExtent(Rect *qdExtent);
- /* Returns a Quickdraw rect the size of our extent in 'qdExtent'. */
-
- virtual pascal void GetFrame(VRect *itsFrame);
- /* Returns in'itsFrame' a VRect that is the boundary of our view in superview
- coordinates. This is calculated by adding its size to its location. */
-
- virtual pascal void GetVisibleRect(Rect *visQDRect);
- /* Retuns a Quickdraw rect the size of the visible amount of our view. */
-
- virtual pascal void ViewEnable(Boolean state, Boolean redraw);
- /* Enables & Redraws the view based on 'state' & 'redraw'. */
-
- virtual pascal Boolean IsViewEnabled(void);
- /* Checks to see if our view is currently enabled. */
-
- virtual pascal void Show(Boolean state, Boolean redraw);
- /* If 'state' is not fShown then set fShown to TRUE and call ForceRedraw if 'redraw'
- is TRUE. Otherwise invalidate our focus and set fShown to 'state'. */
-
- virtual pascal Boolean IsShown(void);
- /* Checks to see if our view is currently shown. */
-
- virtual pascal Boolean IsVisible(void);
- /* Returns TRUE if any portion of the view is currently visible when focused */
-
- /* Clipboard Handling */
-
- virtual pascal Boolean ContainsClipType(ResType aType);
- /* Checks to see if the clipboard contains the type 'aType'. */
-
- virtual pascal long GivePasteData(Handle aDataHandle, ResType dataType);
-
- /* Gets the scrap data of the type 'dataType', returns any errors as function result. */
-
- virtual pascal void WriteToDeskScrap(void);
- /* Writes to desk scrap. */
-
- /* PrintingMethods */
-
- virtual pascal void AttachPrintHandler(struct TPrintHandler *itsPrintHandler);
- /* Called by the PrintHandler during its initialization, NOT directly by you */
-
- virtual pascal VCoordinate DoBreakFollowing(VHSelect vhs, VCoordinate prevBreak, Boolean *
- automatic);
- /* Returns the location of the page break which follows the page break located at
- 'prevBreak', in direction vhs; returns automatic = TRUE if the page-break is
- thought of as an 'automatic' rather than a 'manual' (user-specified) one. Note that
- page-breaks in dimension 'v' are drawn as vertical lines, those in dimension 'h' as
- horizontal lines */
-
- virtual pascal void DoCalcPageStrips(Point *pageStrips);
- /* Computes the number of horizontal and vertical page strips. */
-
- virtual pascal void DoCalcViewPerPage(VPoint *viewPerPage);
- /* Determine how much of the view normally goes into each printed page, in each
- dimension. */
-
- virtual pascal void DoCheckPrinter(void);
-
- /* Check whether printer (if relevant) has changed, and if so, take appropriate action
- */
-
- virtual pascal void DoDrawPrintFeedback(Rect *area);
- /* Draw page-breaks, page-numbers, view-borders, rulers, etc. */
-
- virtual pascal void DoDrawPageBreak(VHSelect vhs, short whichBreak, VCoordinate loc, Boolean
- automatic);
- /* Draw one page break. */
-
- virtual pascal struct TCommand *DoMenuCommand(CmdNumber aCmdNumber);
- /* Enables my fPrintHandler to handle commands */
-
- virtual pascal void DoPagination(void);
- /* Recompute the dividing lines between areas of the view which will be mapped into
- different printed pages */
-
- virtual pascal void DoPrinterChanged(void);
-
- /* The metrics relating to printer use have changed; absorb the information and react
- */
-
- virtual pascal void DoSetPageOffset(VPoint *coord);
- /* Only reimplement in very unusual circumstances involving Tall-UnAdjusted text
- printing etc. */
-
- virtual pascal void DoSetupMenus(void);
- /* Tells my PrintHandler to set up its menus */
-
- virtual pascal void GetPrintExtent(VRect *printExtent);
- /* Returns the part of the view that is to be printed. The default is to return the
- view's extent. */
-
- virtual pascal void PageInteriorChanged(Rect *newInterior);
- /* Allows a view which is printable to react to the changing of the page-interior
- rectangle */
-
- /* Inspecting Methods */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Called by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- virtual pascal void GetInspectorName(StringPtr inspectorName);
- /* Called by the Inspector to get the name of this class. */
-
- /* Tracking Methods */
-
- virtual pascal Boolean IsDoneTracking(void);
- /* Indicates whether the Tracker is through tracking. (the command is also through
- tracking if you return NIL from TrackMouse). Defaults to NOT StillDown.
- Most programs won't have to mess with this.
- NOTE you still have to deal with queued events if you change the criteri
- a for TRUE. */
-
- virtual pascal void TrackConstrain(VPoint *anchorPoint, VPoint *previousPoint, VPoint *nextPoint
- );
- /* Override this if your Tracker calls back to the view (the Default) an you want to
- constrain the mouse point to a grid, force drawing a square, etc. This i
- s called only
- if fConstrainsMouse is TRUE. */
-
- virtual pascal void TrackFeedback(VPoint *anchorPoint, VPoint *nextPoint, Boolean turnItOn,
- Boolean mouseDidMove);
- /* Override this if your Tracker calls back to the view (the Default) an you want to
- display any tracking feedback */
-
- virtual pascal void TrackMouse(TrackPhase aTrackPhase, VPoint *anchorPoint, VPoint *
- previousPoint, VPoint *nextPoint, Boolean mouseDidMove);
- /* Override this if your Tracker calls back to the view (the Default) an you want to
- display any tracking feedback */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- /* Set by GetFocus; used by SetFocus. GetFocus/SetFocus are used to save and restore the
- focus
- behind MacApp's back. One use is to speed up scrolling (see TScroller). */
- #if ! qExperimentalAndUnsupported
- struct FocusRec {
- Boolean printing;
- Boolean drawingPictScrap;
- struct TView *drawingPictScrapView;
- struct TView *focusedView;
- VPoint longOffset;
- Point org;
- GrafPtr port;
- RgnHandle clip;
- Boolean isValid; /* TRUE if FocusRec is valid */
- };
- #endif
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- struct ScrollerTemplate {
- Boolean wantVSBar;
- Boolean wantHSBar;
- long vertMax;
- long horzMax;
- short vScrollUnits;
- short hScrollUnits;
- Boolean vConstrain;
- Boolean hConstrain;
- Rect sBarOffsets;
- };
- typedef ScrollerTemplate *ScrollerTemplatePtr;
-
- class TScroller : public TView {
- public: /* A view which can "scroll" its contents by
- translating coordinates. */
-
- VPoint fTranslation; /* the current amount of translation */
- VPoint fScrollLimit; /* the 'limit' of the subview that should be
- scrollable */
- VPoint fMaxTranslation; /* the derived maximum amount of translation
- taking into account the visible portion of
- the view. This keeps us from scrolling the
- bottom of a view to the top of a window */
- struct TSScrollBar *fScrollBars[2];
- /* associated scroll bars if any
- */
- Point fScrollUnit; /* increment of scroll */
- Boolean fConstrain[2]; /* should scrolling be constrained
- to a multiple of my scrollunit */
- VRect fSBarOffsets; /* how much to offset the associated scroll
- bars from my bounds */
- Boolean fRespondsToFunctionKeys; /* if it responds to PgUp/PgDn, etc. */
-
- /* Creation/Destruction Methods */
-
- virtual pascal void IScroller(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize,
- SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, VCoordinate itsHorzMax, VCoordinate
- itsVertMax, Boolean wantHorzSBar, Boolean wantVertSBar);
- /* Called to initialize a scroller procedurally. */
-
- virtual pascal void CreateScrollBar(VHSelect itsDirection);
- /* Called to create a scrollbar in 'itsDirection'. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize a scroller from a resource template. */
-
- virtual pascal void CreateTemplateScrollBar(VHSelect itsDirection);
- /* Called to create a scrollbar in 'itsDirection' from a resource template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* For writing a scroller view out to a resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* For writing a scroller to a resource, works in conjunction with tbe previous
- method. */
-
- virtual pascal void Free(void);
- /* If there are attached scrollbars frees them before calling inherited Free. */
-
- /* SubView Management Methods */
-
- virtual pascal void AddSubView(TView *theSubView);
-
- /* Calls inherited AddSubView and then calls 'theSubView' to BeInScroller passing SELF
- as the scroller to be in. */
-
- virtual pascal void RemoveSubView(TView *theSubView);
- /* Calls BeInScroller with a parameter of NIL, for 'theSubView', before calling
- inherited RemoveSubView. */
-
- /* Focusing Methods */
-
- virtual pascal Boolean Focus(void);
- /* Attempts to Focus the scroller by calling inherited Focus and setting the
- gLongOffset */
-
- virtual pascal void ForceRedraw(void);
- /* Invalidates the entire view forcing a redraw. */
-
- /* Miscellaneous Methods */
-
- virtual pascal void LocalToSuper(VPoint *thePoint);
- /* Given a point in local coordinates, returns the same point in its superview's
- coordinate system. */
-
- virtual pascal void SuperToLocal(VPoint *thePoint);
- /* Given a point in superview coordinates, returns the same point in the view's own
- coordinate system. */
-
- virtual pascal void GetExtent(VRect *itsExtent);
- /* Returns the extent of the scroller. */
-
- /* Size Methods */
-
- virtual pascal void Resize(VCoordinate width, VCoordinate height, Boolean invalidate);
- /* Resizes the scroller to 'width' & 'height', redrawing if 'invalidate' is TRUE. */
-
- /* Location Methods */
-
- virtual pascal void Locate(VCoordinate h, VCoordinate v, Boolean invalidate);
- /* Calls inherited Locate before calling AdjustScrollbars. */
-
- virtual pascal void AdjustScrollBars(Boolean invalidate);
- /* Resizes and re-Locates the scrollbars if required. */
-
- virtual pascal void SubViewChangedSize(TView *theSubView, VPoint *delta);
- /* Adjust the scroll limits based on the size change of the subviews. */
-
- virtual pascal void SetScrollLimits(VPoint *scrollLimit, Boolean drawScrollBars);
- /* Sets the scroll of the attached scrollbars, if there are any. */
-
- virtual pascal void SetScrollParameters(VCoordinate horzUnits, VCoordinate vertUnits, Boolean
- horzConstraint, Boolean vertConstraint);
- /* Sets up the fScrollUnit and fConstrain fields of the scroller. */
-
- /* Scrolling Methods */
-
- virtual pascal void HaveScrollBar(struct TSScrollBar *theScrollBar, VHSelect direction);
- /* Sets the fScrollbar field in the given 'direction' to 'theScrollBar'. */
-
- virtual pascal void ScrollDraw(VPoint *delta, Boolean invalidate);
-
- /* Method responsible for actually doing the scrolling by calling moving bits. Called
- by DoScroll. Invalidates newly revealed area if invalidate is true else updates
- the redraws the newly revealed area if invalidate is false.
- !!! NOTE this does not match the behaviour of other invalidate parameter
- s because they
- interpret invalidate equals FALSE to neither draw nor invalidate. Well we already
- know that the way that invalidate/redraw/don't-render control is handled
- needs _MAJOR_
- overhauling anyways… Sigh! */
-
- virtual pascal void DoScroll(VPoint *delta, Boolean redraw);
- /* Method responsible for handling the scrolling, calls ScrollDraw if required. */
-
- virtual pascal VCoordinate ScrollStep(VHSelect vhs, short partCode);
- /* Depending on the 'partCode' returns the amount to be scrolled. */
-
- virtual pascal VCoordinate ScrollRelative(VHSelect vhs, VCoordinate sBarValue);
- /* Returns the relative amount to scroll. */
-
- virtual pascal void ScrollBy(VCoordinate deltaH, VCoordinate deltaV, Boolean redraw);
- /* Called to scroll by 'deltaH & 'deltaV'. */
-
- virtual pascal void ScrollTo(VCoordinate h, VCoordinate v, Boolean redraw);
- /* Scroll to the required coordinates, calls ScrollBy. */
-
- virtual pascal void AutoScroll(VPoint *viewPt, VPoint *delta);
- /* Called during auto scrolling to return the delta to be scrolled. */
-
- virtual pascal void RevealRect(VRect *rectToReveal, Point minToSee, Boolean redraw);
- /* Shows 'rectToReveal' with the minimum amount to be seen set to 'minToSee' by
- calling ScrollBy. */
-
- /* Miscellaneous Methods */
-
- virtual pascal struct TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
- /* Handles when the Home, End, PageUp & PageDown keys are used. */
-
- virtual pascal TScroller *GetScroller(Boolean immediateSuperView);
- /* Returns SELF. */
-
- /* Inspecting Methods */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- struct WindowTemplate {
- short procID;
- unsigned hasGoAway : 1;
- unsigned resizable : 1;
- unsigned isModal : 1;
- unsigned doFirstClick : 1;
- unsigned freeOnClosing : 1;
- unsigned disposeOnFree : 1;
- unsigned closesDocument : 1;
- unsigned openInitially : 1;
- unsigned mustAdaptToScreen : 1;
- unsigned stagger : 1;
- unsigned mustForceOnScreen : 1;
- unsigned vertCenter : 1;
- unsigned horzCenter : 1;
- unsigned filler : 3;
- ResType targetID;
- Str255 title; /*Actually variable length*/
- };
- typedef WindowTemplate *WindowTemplatePtr;
-
- class TWindow : public TView {
- public: /* Corresponds to a desktop Window. The
- outermost of a nested set of views. */
- GrafPtr fWMgrWindow; /* the window manager window Ptr */
- short fProcID; /* the proc ID of the window */
- Rect fMoveBounds; /* bounds over which the window may be moved
- */
- Rect fResizeLimits; /* limits over which the window may be
- resized */
- TEvtHandler *fTarget; /* when this window is activated; the
- TEvtHandler to SetTarget on */
- ResType fTargetID; /* corresponding ID to fTarget */
- short fPreDocname; /* amount of window title that precedes the
- document name */
- short fConstTitle; /* amount of the title name that is constant
- */
- Boolean fIsActive; /* is this window active */
- Boolean fIsResizable; /* is this window resizeable */
- Boolean fIsClosable; /* is this window closable */
- Boolean fFreeOnClosing; /* should this window free itself when it
- closes */
- Boolean fDisposeOnFree; /* should the window manager window be
- disposed when this window frees */
- Boolean fClosesDocument; /* does this window close the document */
- Boolean fOpenInitially; /* should this window be opened when its
- document is asked to show its windows */
- Boolean fIsModal; /* should this window behave modally */
- Boolean fDoFirstClick; /* should a click in this window not only
- select it if it is inactive but also be
- sent to its contents */
- Boolean fMustAdapt; /* does this window require adaption to the
- screen */
- Boolean fMustHorzCenter; /* does this window require centering
- horizontally */
- Boolean fMustVertCenter; /* does this window require centering
- vertically */
- Boolean fMustStagger; /* does this window require staggering */
- Boolean fMustForceOnScreen; /* does this window require forcing on the
- screen */
- Boolean fAdapted; /* has this window's size ever been adapted
- to the screen */
- Boolean fHorzCentered;
- /* has this window been centered horizontally
- */
- Boolean fVertCentered;
- /* has this window been centered vertically */
- Boolean fStaggered; /* has this window been staggered */
- Boolean fForcedOnScreen; /* has this window been forced on the screen
- */
- Boolean fFloats; /* does this window float above non-floating
- windows (NOT SUPPORTED IN 2.0) */
- Point fContRgnInset; /* topleft inset of cont rgn in struc rgn */
- Point fContDifference; /* total amount the content is less than and
- offset into the structure (Accounts for
- title bar, etc.) */
-
- /* Creation/Destruction Methods */
-
- virtual pascal void IWindow(TDocument *itsDocument, GrafPtr itsWMgrWindow, Boolean canResize,
- Boolean canClose, Boolean disposeOnFree);
- /* Initialize a window procedurally. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize a window from a resource template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* For writing a window out to a resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* For writing a TWindow to a resource, works in conjunction with tbe previous
- method. */
-
- virtual pascal void Free(void);
- /* Frees the window if fDisposeOnFree is TRUE, also deletes the window from the
- document if there is one, otherwise deletes it from the applications list of free
- windows. */
-
- /* Open/Close Methods */
-
- virtual pascal void Open(void);
- /* Makes the window visible by showing it before calling inherited Open. */
-
- virtual pascal void Close(void);
- /* Calls inherited Close and the hides & deactivates the window. */
-
- virtual pascal void CloseByUser(void);
- /* If the window is shown and it can be closed handles the closing. */
-
- virtual pascal void GoAwayByUser(Point globalMouse);
- /* Responsible for calling CloseByUser. */
-
- /* Activation Methods */
-
- virtual pascal void Activate(Boolean entering);
- /* Activate the window. */
-
- /* Size/Location Methods */
-
- virtual pascal void Locate(VCoordinate h, VCoordinate v, Boolean invalidate);
- /* If fWMgrWindow is not NIL then MoveWindow to relocate the window. */
-
- virtual pascal void MoveByUser(Point globalMouse);
- /* Handles the user moving the window by dragging the title bar, calls DragWindow to
- handle movement. */
-
- virtual pascal void ResizeByUser(Point globalMouse);
- /* Handles the user resizing the window by dragging the growbox, calls GrowWindow to
- handle movement and Resize to resize the window. */
-
- virtual pascal void Resize(VCoordinate width, VCoordinate height, Boolean invalidate);
- /* Used to resize the window by setting its width & height to the parameters passed
- in. */
-
- virtual pascal void Zoom(short partCode);
- /* Responsible for actually handling the zooming of a window when the user clicks in
- the zoombox. */
-
- virtual pascal void ZoomByUser(Point globalMouse, short partCode);
- /* handles the user clicking in the zoombox to zoom the window, calls Zoom. */
-
- /* Focusing Methods */
-
- virtual pascal Boolean Focus(void);
-
- /* Attempts to set the Focus to the window, returns TRUE if it succeeds, FALSE if not.
- */
-
- virtual pascal Boolean FocusOnSuperView(void);
-
- /* Attempts to set the Focus to our superview, returning TRUE if it succeeds or FALSE
- if not. */
-
- /* Drawing Methods */
-
- virtual pascal void DrawContents(void);
-
- /* Does an EraseRect and calls inherited DrawContents before calling DrawResizeIcon. */
-
- virtual pascal void DrawResizeIcon(void);
- /* Draws the grow icon by calling the toolbox routine DrawGrowIcon. */
-
- /* Mouse Handling Methods */
-
- virtual pascal Boolean HandleMouseDown(VPoint *theMouse, EventInfo *info, Point *hysteresis,
- struct TCommand **theCommand);
- /* Handles mouse downs in the window. */
-
- virtual pascal Boolean HasPendingUpdate(void);
- /* Returns TRUE if there is a pending update event for this window, FALSE if not. */
-
- virtual pascal void Update(void);
- /* Handle the update region and drawcontents on SELF. */
-
- /* Menu Handling Methods*/
-
- virtual pascal Boolean AllowsMenuAccess(void);
- /* By default returns TRUE. */
-
- virtual pascal void DoSetupMenus(void);
- /* If the window is not modal calls inherited DoSetupMenus. */
-
- virtual pascal struct TCommand *DoMenuCommand(CmdNumber aCmdNumber);
- /* Handles closing the window. */
-
- /* Misc. Methods */
-
- virtual pascal void Show(Boolean state, Boolean redraw);
- /* Called to make the window visible or not based on 'state'. */
-
- virtual pascal Boolean IsShown(void);
- /* Returns TRUE if the window is currently shown. */
-
- virtual pascal void Select(void);
- /* Called to select the window. */
-
- virtual pascal void SetTitle(StringPtr newTitle);
- /* Sets the windows title to 'newTitle'. */
-
- virtual pascal void GetTitle(StringPtr theTitle);
- /* Gets the current title of the window. */
-
- virtual pascal void SetTitleForDoc(StringPtr newDocTitle);
- /* Called when the documents name is known or changed */
-
- virtual pascal void AdaptToScreen(void);
- /* Resizes the window to fit the screen on which it is being displayed. */
-
- virtual pascal void ForceOnScreen(void);
- /* ForceOnScreen gaurantees that some minimal drag area is accessible to the user,
-
- to be dragged to the desired location. */
-
- virtual pascal void Center(Boolean horizontally, Boolean vertically, Boolean forDialog);
- /* Centers the window on the screen either horizontally, vertically or both. */
-
- virtual pascal void SimpleStagger(short dh, short dv, short *counter);
- /* Handles the staggering of windows as they are opened. */
-
- virtual pascal GrafPtr GetGrafPort(void);
- /* Returns the windows GrafPtr. */
-
- virtual pascal void GetGlobalBounds(Rect *globalBounds);
- /* Returns a rectangle that is the global bounds of the window. */
-
- virtual pascal GDHandle GetMaxIntersectedDevice(Rect *screenRect);
- /* Returns the screenRect of the most intersected device & its GDHandle, or
- if CQD isn't available it returns GetGrayRgn intersected with screenbits.bounds
- and NIL for the GDHandle. */
-
- virtual pascal TWindow *GetWindow(void);
- /* Returns SELF. */
-
- virtual pascal void SetResizeLimits(Point itsMinSize, Point itsMaxSize);
- /* Used to set the limits to which the window can be resized. */
-
- virtual pascal void SetTarget(TEvtHandler *newTarget);
- /* Set fTarget to 'newTarget' and if we are the active window then call
- gApplication.SetTarget. */
-
- virtual pascal void InstallDocument(TDocument *itsDocument);
- /* Sets our fDocument field to 'itsDocument' and then installs the SELF in the
- document, if the document is not NIL. */
-
- virtual pascal Boolean IsDraggable(Rect *whichRect);
- /* Returns TRUE if any of the corner points of whichRect are draggable. */
-
- virtual pascal Boolean BuildWindowRgns(Boolean build);
- /* IF build=kBuild THEN ensures that the window regions are valid; sets
- fContRgnInset, fContDifference.
- Cleans up if necessary, when done with window regions.
- Returns the old state of the window regions. */
-
- /* Inspecting Methods */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- virtual pascal void GetInspectorName(StringPtr inspectorName);
- /* Used by the Inspector to get the name of this class. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- struct ControlTemplate {
- CntlAdornment itsAdornment;
- Byte filler1;
- Point itsPenSize;
- unsigned isSizable : 1;
- unsigned isDimmed : 1;
- unsigned isHilited : 1;
- unsigned canDismiss : 1;
- unsigned filler2 : 12;
- Rect itsInset;
- Style itsTextFace;
- short itsTextSize;
- RGBColor itsTextColor;
- Str255 itsFontName; /*Actually a variable length P-String*/
- };
- typedef ControlTemplate *ControlTemplatePtr;
-
- class TControl : public TView {
- public: /* An abstract class that represents a
- control. */
- short fDefChoice; /* the choice to automatically pass up the
- line via DoChoice */
- Boolean fHilite; /* is this view hilited */
- Boolean fDimmed; /* is this view dimmed */
- Boolean fSizeable; /* is the control portion of this view
- sizeable */
- Boolean fDismissesDialog; /* can this view dismiss it's dialogview */
- CntlAdornment fAdornment; /* the adornment to be drawn in addition to
- the view */
- Point fPenSize; /* pen size to be used in adorning */
- Rect fInset;
- /* amount to inset the control portion of the
- view */
- TextStyle fTextStyle; /* the TextStyle to use when rendering this
- view */
-
- virtual pascal void IControl(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize,
- SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet);
- /* Initialize a control procedurally. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize a control from a resource template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* For writing a control view out to a resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* For writing a control view to a resource, works in conjunction with tbe previous
- method. */
-
- virtual pascal void ComputeSize(VPoint *newSize);
- /* Called to compute the control's size. */
-
- virtual pascal Boolean ContainsMouse(VPoint *theMouse);
- /* Returns TRUE if 'theMouse is currently in the controls area. */
-
- virtual pascal void ControlArea(Rect *theArea);
- /* Returns in 'theArea' the controls active area. */
-
- virtual pascal void Dim(void);
- /* Dims the control by drawing over it with a gray pattern. */
-
- virtual pascal void DimState(Boolean state, Boolean redraw);
- /* If we are not currently dimmed then set fDimmed to 'state.and if 'redraw' is TRUE
- then call DrawContents. */
-
- virtual pascal struct TCommand *DoMouseCommand(Point *theMouse, EventInfo *info, Point *
- hysteresis);
- /* Creates a control tracker command, which is returned. */
-
- virtual pascal void Draw(Rect *area);
- /* Calls Adorn to handle any adornments and the Dim & Hilite if required. */
-
- virtual pascal Boolean Focus(void);
- /* Calls inherited Focus and if its TRUE then sets the port's text style and returns
- TRUE, if it can't be focused returns FALSE. */
-
- virtual pascal void Flash(void);
- /* Causes a control to flash with an 8 tick delay. */
-
- virtual pascal void Hilite(void);
- /* Hilites the control by inverting its controlarea. */
-
- virtual pascal void HiliteState(Boolean state, Boolean redraw);
- /* If our fHilite is not 'state' the set it to 'state' before calling Hilite. Note:
- hilite is only called if 'redraw is TRUE and we can Focus. */
-
- virtual pascal void Inset(short dh, short dv, Boolean redraw);
-
- /* If we are sizable then offset fInset to 'dh' & 'dv' redrawing if 'redraw' is TRUE.
- */
-
- virtual pascal Boolean IsDimmed(void);
- /* Returns TRUE if the control is currently dimmed. */
-
- virtual pascal void SetInset(Rect *newInset, Boolean redraw);
- /* Set fInset to 'newInset' redrawing if 'redraw' is TRUE. */
-
- virtual pascal void InstallColor(RGBColor *theColor, Boolean redraw);
-
- /* Sets the color field of our text style record to 'theColor', if 'redraw' then call
- DrawContents. */
-
- virtual pascal void InstallTextStyle(TextStyle *theTextStyle, Boolean redraw);
- /* Sets fTextStyle to 'theTextStyle', if 'redraw' then call DrawContents. */
-
- virtual pascal void Resize(VCoordinate width, VCoordinate height, Boolean invalidate);
- /* Calls inherited Resize before calling ForceRedraw. */
-
- virtual pascal void TrackFeedback(VPoint *anchorPoint, VPoint *nextPoint, Boolean turnItOn,
- Boolean mouseDidMove);
- /* Doesn't use the default feedback */
-
- virtual pascal void TrackMouse(TrackPhase aTrackPhase, VPoint *anchorPoint, VPoint *
- previousPoint, VPoint *nextPoint, Boolean mouseDidMove);
- /* Called back from tracking command. Handles tracking of the mouse and then calls
- DoChoice on TrackRelease. */
-
- virtual pascal long Validate(void);
- /* By default returns 'noErr'. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TCtlMgr : public TControl {
- public: /* An abstract class that represents a
- toolbox Control Manager control. */
- ControlHandle fCMgrControl; /* the Control Manager Control that is being
- managed */
- short fBitsToShift; /* # bits shifted to convert between short
- and long value. */
- VCoordinate fLongVal; /* the current value */
- VCoordinate fLongMin; /* the minimum setting */
- VCoordinate fLongMax; /* the maximum setting */
-
- virtual pascal void ICtlMgr(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize,
- SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, StringPtr itsTitle, long itsVal, long
- itsMin, long itsMax, short itsProcID);
- /* Initialize procedurally. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize from a resource template. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* For writing a CtlMgr view to a resource. */
-
- virtual pascal void Free(void);
-
- /* Set the size of control to zero call DisposeControl, then call inherited Free. */
-
- virtual pascal void BeInPort(GrafPtr itsPort);
- /* Sets the control to be in 'itsPort', by setting the contrlOwner field of the
- ControlHandle. */
-
- virtual pascal void CreateCMgrControl(Rect *itsBounds, StringPtr itsTitle, long itsVal, long
- itsMin, long itsMax, short itsProcID);
- /* Used to create a new control, calls NewControl to create the control. */
-
- virtual pascal void DimState(Boolean state, Boolean redraw);
- /* Set the dim state to 'state' and redrawing it if 'redraw'. */
-
- virtual pascal struct TCommand *DoMouseCommand(Point *theMouse, EventInfo *info, Point *
- hysteresis);
- /* Handles mouse downs in the control by calling TestControl and DoChoice, returns
- NIL. */
-
- virtual pascal void Draw(Rect *area);
- /* Draws the control by calling the toolbox routine ShowControl. */
-
- /* Methods to manipulate the TCtlMgr values */
- virtual pascal VCoordinate GetLongMax(void);
- /* Returns the current fLongMax value. */
-
- virtual pascal VCoordinate GetLongMin(void);
- /* Returns the current fLongMin value. */
-
- virtual pascal VCoordinate GetLongVal(void);
- /* Returns the current fLongVal value. */
-
- virtual pascal void SetLongMax(VCoordinate itsMax, Boolean redraw);
- /* Sets fLongMax to 'itsMax', redrawing if required. */
-
- virtual pascal void SetLongMin(VCoordinate itsMin, Boolean redraw);
- /* Sets flongMin to 'itsMin', redrawing if required. */
-
- virtual pascal void SetLongVal(VCoordinate itsVal, Boolean redraw);
- /* Sets fLongVal to 'itsVal' redrawing if required. */
-
- virtual pascal void SetLongValues(VCoordinate itsVal, VCoordinate itsMin, VCoordinate itsMax,
- Boolean redraw);
- /* Sets all of the values at once, redrawing if required. */
-
- /* Methods to manipulate the Control Manager control values */
- virtual pascal short GetMax(void);
- /* Returns the maximum value of the Control Manager control. */
-
- virtual pascal short GetMin(void);
- /* Returns the minimum value of the Control Manager control. */
-
- virtual pascal void GetText(StringPtr theText);
- /* Returns the controls title, if any. */
-
- virtual pascal short GetVal(void);
- /* Returns the current value of the Control Manager control. */
-
- virtual pascal void SetMax(short itsMax, Boolean redraw);
-
- /* While focused sets the maximum value of the Control Manager control to 'itsMax'. */
-
- virtual pascal void SetMin(short itsMin, Boolean redraw);
-
- /* While focused sets the minimum value of the Control Manager control to 'itsMin'. */
-
- virtual pascal void SetText(StringPtr itsText, Boolean redraw);
- /* Sets the controls title to 'itsText', redrawing if required. */
-
- virtual pascal void SetVal(short newVal, Boolean redraw);
- /* While focused sets the Control Manager controls value to 'newVal', redrawing if requi
- red. */
-
- virtual pascal void SetValues(short itsVal, short itsMin, short itsMax, Boolean redraw);
- /* While focused sets all the values of the Control Manager control, at once, redrawing
- if required. */
-
- virtual pascal void HiliteState(Boolean state, Boolean redraw);
-
- /* Set the hilite state to 'state', redrawing if required.If hilite state is currently
- 'state' then does nothing. */
-
- virtual pascal Boolean IsCMgrVisible(void);
- /* Returns TRUE if the control is currently visible, FALSE if not. */
-
- virtual pascal void Resize(VCoordinate width, VCoordinate height, Boolean invalidate);
- /* If the control is resizable calls the toolbox routines MoveControl & SizeControl
- before calling inherited Resize. */
-
- virtual pascal void SetCMgrVisibility(Boolean beVisible);
- /* Sets the visibility of the control to 'isVisible'. */
-
- virtual pascal void WhileFocused(pascal void (*DoToControl)(void *DoToControl_StaticLink), void
- *DoToControl_StaticLink, Boolean redraw);
- /* While focused call "DoToControl", redrawing if required. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- struct ScrollBarTemplate {
- long value;
- long minimum;
- long maximum;
- };
- typedef ScrollBarTemplate *ScrollBarTemplatePtr;
-
- class TScrollBar : public TCtlMgr {
- public: /* A subclass of TCtlMgr that maps between
- longint values for our view coordinates
- and the integers of a toolbox scrollbar. */
- VHSelect fDirection;
- /* is this a horizontal or vertical scrollbar
- */
-
- virtual pascal void IScrollBar(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize,
- SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, VHSelect itsDirection, long itsVal,
- long itsMin, long itsMax);
- /* Initialize a scrollbar procedurally. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize a scrollbar from a resource template. */
-
- virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* For writing a dialog view out to a resource. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* For writing a scrollbar to a resource, works in conjunction with tbe previous
- method. */
-
- virtual pascal void DeltaValue(VCoordinate delta);
- /* Does range checking on 'delta' checking it against fLongMin & fLongMax for the
- scrollbar. */
-
- virtual pascal struct TCommand *DoMouseCommand(Point *theMouse, EventInfo *info, Point *
- hysteresis);
- /* Handles the mouse down in the various parts of the scrollbar. */
-
- virtual pascal void TrackScrollBar(short partCode);
- /* Tracks the scrollbar by calling DeltaValue. */
-
- virtual pascal void ActionProc(short partCode);
-
- /* Forwarded to from the global routine: ActionProcForTScrollBar which was set as the
- ScrollBar's action proc. Typically forwards again to TrackScrollBar after bounds
- checking and Updates before returning to the ScrollBar. */
-
- /* Inspecting */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents to this class's
- fields. */
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TSScrollBar : public TScrollBar {
- public: /* A subclass of TScrollBar that is
- associated with one or more scrollers. */
- TList *fScrollers; /* the associated scrollers if any */
-
- virtual pascal void ISScrollBar(TView *itsSuperView, VPoint *itsLocation, VPoint *itsSize,
- SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, VHSelect itsDirection, long itsMax,
- TScroller *itsScroller);
- /* Initialize the scrollbar procedurally. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize the scrollbar from a resource template. */
-
- virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
- /* For writing an sscrollbar out to a resource. */
-
- virtual pascal void Free(void);
- /* If the scrollers are not NIL then first detach the scrollbars from them before
- freeing the scrollers, then call inherited Free. */
-
- virtual pascal void AttachScroller(TScroller *itsScroller);
-
- /* IF 'itsScroller' is not NIL then add it to our list and attach ourselves to it. */
-
- virtual pascal void BeInPort(GrafPtr itsPort);
- /* Call inherited BeInPort and then set our visibility based on the state of the
- window we are in. */
-
- virtual pascal void Activate(Boolean entering);
- /* If 'entering' is TRUE then show ourselves, otherwise just call Draw to frame our
- area. */
-
- virtual pascal struct TCommand *DoMouseCommand(Point *theMouse, EventInfo *info, Point *
- hysteresis);
- /* Handles mouse downs in the scrollbar. */
-
- virtual pascal void Draw(Rect *area);
- /* Draws a frame around the controls area before calling inherited Draw. */
-
- virtual pascal void TrackScrollBar(short partCode);
- /* Called to handle tracking of the scrollbar by calling DeltaValue. */
-
- /* Inspecting */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TDeskScrapView : public TView {
- public:
- /* The default view in the Clipboard, able to
- display only standard text and pictures. */
- Boolean fHavePicture; /* are we holding a PICT */
- Boolean fHaveText; /* is there any TEXT */
- short fScrapCount; /* scrapCount of the scrap represented by
- this view.*/
-
- Handle fDataHandle; /* if non-NIL, will be either a PicHandle to
- my picture or a Handle to my Text */
-
- virtual pascal void IDeskScrapView(void);
- /* Initialize the deskscrap view procedurally. */
-
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
- /* Initialize the deskscrap view from a resource template. */
-
- virtual pascal void Free(void);
- /* Does nothing, don't ever want to free gClipOrphange. */
-
- virtual pascal void CheckScrapContents(void);
- /* Checks the contents of the deskscrap. */
-
- virtual pascal void CalcMinSize(VPoint *minSize);
- /* Responsible for calculating the correct size for the deskscrap view. */
-
- virtual pascal void Draw(Rect *area);
-
- /* handles the drawing of the contents of the deskscrap, which by default is either a
- PICT or text. */
-
- virtual pascal void SuperViewChangedSize(VPoint *delta, Boolean invalidate);
- /* If our superview changes size then call AdjustSize & ForceRedraw. */
-
- virtual pascal void WriteToDeskScrap(void);
- /* This view represents data that is already written to the deskscrap, so this does
- nothing. */
-
- /* Inspecting */
- virtual pascal void GetInspectorName(StringPtr inspectorName);
- /* Used by the Inspector to get the name of this class. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TPrintHandler : public TEvtHandler {
- public:
- /* Handles printing at a specified resolution
- on behalf of a view. This class is really
- a non-functional stub for programs that
- don't use the printing building block. */
- TView *fView; /* The view whose printing is handled */
- TDocument *fDocument; /* the document printed by this handler */
- Point fDeviceRes; /* formal printer resolution, spots per inch
- */
- VPoint fViewPerPage; /* The amount of the view that is visible on
- a page */
- short fFocusedPage; /* The page number currently focused */
-
- /* Initialization and termination */
-
- virtual pascal void IPrintHandler(TView *itsView);
- /* Initialize the printHandler, and associate it and 'itsView' with each other */
-
- virtual pascal void GetInspectorName(StringPtr inspectorName);
- /* Used by the inspector to get the name of this class. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- virtual pascal void FocusOnInterior(void);
- /* Stub */
-
- virtual pascal void SetDefaultPrintInfo(void);
- /* Stub */
-
- /* Printing-related reformatting and computations */
-
- virtual pascal VCoordinate BreakFollowing(VHSelect vhs, VCoordinate prevBreak, Boolean *
- automatic);
- /* Returns the location of the page break which follows the page break located at
- 'prevBreak', in direction vhs; returns automatic = TRUE if the page-break is
- thought of as an 'automatic' rather than a 'manual' (user-specified) one. Note that
- page-breaks in dimension 'v' are drawn as vertical lines, those in dimension 'h' as
- horizontal lines */
-
- virtual pascal void CalcPageStrips(Point *pageStrips);
- /* Recalculate the number of strips of pages in each dimension */
-
- virtual pascal void CalcViewPerPage(VPoint *amtPerPage);
-
- /* Computes the amount of view, in each dimension, to be allocated to a printed page */
-
- virtual pascal void CheckPrinter(void);
- /* See if there are changed printer-configuration parameters which need to be
- absorbed, and if so, absorb them */
-
- virtual pascal void LocatePageInterior(short pageNumber, Point *loc);
- /* Decide where the top-left-most point of the the interior of the page should be */
-
- virtual pascal void PrinterChanged(void);
-
- /* The metrics relating to printer use have changed; absorb the information and react
- */
-
- virtual pascal void RedoPageBreaks(void);
- /* Recompute the dividing lines between areas of the view which will be mapped into
- different printed pages */
-
- virtual pascal void Reset(void);
- /* Resets the print handler to the default values */
-
- /* Printing-related commands */
-
- virtual pascal struct TCommand *Print(CmdNumber itsCmdNumber, Boolean *proceed); /*+*/
- /* By default sets 'proceed' to TRUE and returns NIL. */
-
- virtual pascal Boolean SetupForFinder(void);
- /* Intended to set up the print handler for finder printing. */
-
- /* Printing-related screen feedback */
-
- virtual pascal void DrawPrintFeedback(Rect *area);
- /* Draw page-breaks, page-numbers, view-borders, rulers, etc. */
-
- virtual pascal void DrawPageBreak(VHSelect vhs, short whichBreak, VCoordinate loc, Boolean
- automatic);
- /* Does nothing. */
-
- /* Actual printing */
-
- virtual pascal short MaxPageNumber(void);
- /* Returns the largest page number which could be reasonably printed, given the
- properties of the view; in cases like a SpreadSheet, this is not necessarily as
- large as the product (row strips) x (column strips) */
-
- virtual pascal void SetPageInterior(short pageNumber);
- /* Set up the pad-space Interior rectangle for the given page number */
-
- virtual pascal void SetPageOffset(VPoint *coord);
- /* Given the view coordinates of the top-left-most point of the view which is being
- mapped into the current page (in coord), this method's job is to compute the
- correct fRelOrigin field for the current page */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TCommand : public TObject {
- public: /* Handles a user command, including undoing
- and mouse-tracking if required. Usually
- created by the part of the Application
- with the greatest specific knowledge about
- the action to take in response to events
- and passed back to be performed at several
- well defined places.*/
- CmdNumber fCmdNumber;
- /* Can be a many-to-one mapping of fCmdNumber
- to TCommand */
- TView *fView; /* The view affected by this command, and in
- which tracking takes place, if any. */
- TDocument *fChangedDocument; /* the document changed by this command */
- Boolean fCmdDone; /* TRUE if the last "execution" message sent
- to the command was DoIt or RedoIt */
- Boolean fCanUndo; /* Defaults to TRUE */
- Boolean fCausesChange; /* Defaults to TRUE; Marks document changed
- when command is done */
- Boolean fChangesClipboard;
- /* Defaults to FALSE. Set to true for command
- subclasses representing CUT and/ or COPY
- commands which change the Clipboard. */
- Boolean fFreeOnCompletion; /* TRUE to cause the command to be freed on
- completion (the default). Completion is
- after DoIt for non-undoable commands and
- Commit for undoable commands. */
- CommandPriority fPriority; /* How this command should be prioritized if
- it has do compete on a prioritized basis
- for execution. kNormalPriority is the
- Default. Most programs won't have to mess
- with this. */
- Boolean fReadyToExecute; /* TRUE (the default) will enable this
- command to be returned from any queues
- that may be holding it. Most programs
- won't have to mess with this. */
- Boolean fRecurring; /* FALSE (the default) will enable this
- command to be removed from any command
- queue that holds it because it is only
- executed once. */
- /* The remaining fields are for command objects that track the mouse.
- A future version of MacApp will have probably have Trackers as a subclas
- s of TCommand.
- Left now for compatibility (2.0) */
- Boolean fTracksMouse; /* TRUE if the command should be tracked. */
- Point fInitialPt; /* Where to track from (usually where the
- mouse went down) in global coordinates.
- MacApp sets this field in
- TApplication.HandleMooseDown, you set it
- if you create trackers that don't get
- passed back up through that call chain. */
-
- Boolean fConstrainsMouse;
- /* Defaults to FALSE; if you set to TRUE then
- TrackConstrain will be called to constrain
- the mouse. */
- Boolean fViewConstrain; /* Defaults to TRUE, which means constrain
- mouse to view limits */
- Boolean fTrackNonMovement;
- /* Defaults to FALSE, which means don't track
- mouse unless it moves. */
- TScroller *fScroller;
- /* The scroller that handles auto-scrolling */
-
- /* Init & Free */
- virtual pascal void ICommand(CmdNumber itsCmdNumber, TDocument *itsDocument, TView *itsView,
- TScroller *itsScroller);
- /* Initialize a command procedurally. */
-
- /* Inspecting */
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- /* command processing - usually overridden */
-
- virtual pascal void Commit(void);
- /* Stub */
-
- virtual pascal void DoIt(void);
- /* Stub */
-
- virtual pascal void RedoIt(void);
- /* Stub */
-
- virtual pascal void UndoIt(void);
- /* Stub */
-
- /* Scheduling */
- virtual pascal Boolean IsReadyToExecute(void);
-
- /* Returns TRUE (the Default) when the command is ready to execute. Override to base
- the execution of the command on more sophisticated criteria.
- Most programs won't have to mess with this.. */
-
- /* Mouse Tracking */
-
- virtual pascal Boolean IsDoneTracking(void);
- /* Indicates whether the Command is through tracking. (the command is also through
- tracking if you return NIL from TrackMouse). Defaults to fView.IsDoneTracking.
- Most programs won't have to mess with this.
- NOTE you still have to deal with queued events if you change the criteri
- a for TRUE. */
-
- virtual pascal void TrackConstrain(VPoint *anchorPoint, VPoint *previousPoint, VPoint *nextPoint
- );
- /* Override this if you want to constrain the mouse point to a grid, force drawing a
- square, etc. This is called only if fConstrainsMouse is TRUE. */
-
- virtual pascal void TrackFeedback(VPoint *anchorPoint, VPoint *nextPoint, Boolean turnItOn,
- Boolean mouseDidMove);
- /* Default is: IF NOT mouseDidMove THEN FrameRect(<rect formed by anchorPoint and
- nextPoint>). Before this is called the pen is set to PenNormal and the PenMode to
- PatXOR. */
-
- virtual pascal TCommand *TrackMouse(TrackPhase aTrackPhase, VPoint *anchorPoint, VPoint *
- previousPoint, VPoint *nextPoint, Boolean mouseDidMove);
- /* This does the mouse tracking. The default returns SELF. Override it to force
- gridding, to return a different type of command, or to perform the command on mouse
- release instead of using the usual DoIt approach. All points are in local
- coordinates. If aTrackPhase = trackPress then all 3 points will be the same. If
- aTrackPhase = trackRelease then nextPoint will be the coordinate in the mouseUp
- event (if a mouseUp event is found), otherwise the same point as previousPoint.
- Generally, you will ignore nextPoint and just look at previousPoint. mouseDidMove
- will be TRUE if aTrackPhase = trackPress or trackRelease; otherwise, it will
- indicate if nextPoint = previousPoint. If you change anchorPoint, the new value
- will be passed to you next time. The value of nextPoint at the time the routine
- exits will be passed to you as previousPoint the next time the routine is called.
- You can change nextPoint if you wish. Usually, however, you will do gridding in the
- TrackConstrain method. */
-
- virtual pascal void AutoScroll(VCoordinate deltaH, VCoordinate deltaV);
- /* Implements autoscrolling by calling fScroller.ScrollBy. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TNoChangesCommand : public TCommand {
- public: /* Doesn't "change" the document and is not
- itself undoable. Thus it doesn't flush the
- last command that did. Useful for
- deferring actions out to the
- PerformCommand bottleneck where the stack
- is unwound and the heap is unloaded for
- maximum elbow room. */
- virtual pascal void INoChangesCommand(CmdNumber itsCmdNumber, TDocument *itsDocument, TView *
- itsView, TScroller *itsScroller);
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TControlTracker : public TNoChangesCommand {
- public: /* a command adapted for tracking
- controls. */
- TControl *fControl; /* the object of our desire */
-
- virtual pascal void IControlTracker(TControl *theControl);
- /* Initialize the tracker procedurally. */
-
- /* Inspecting */
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- /* commands that are created in response to common operations and will forward to the
- appropriate action */
-
- #if qDebug
- class TDebugCommand : public TNoChangesCommand {
- public: /* Causes the MacApp Debugger to be
- entered */
- virtual pascal void IDebugCommand(CmdNumber itsCmdNumber);
- /* Initialize the DebugCommand procedurally. */
-
- virtual pascal void DoIt(void);
- /* Cause the MacApp Debugger to be entered */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
- #endif
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- #if qInspector
- class TInspectorCommand : public TNoChangesCommand {
- public: /* Tells the inspector to make a new
- window */
- virtual pascal void IInspectorCommand(CmdNumber itsCmdNumber);
- /* Initialize the DebugCommand procedurally. */
-
- virtual pascal void DoIt(void);
- /* Tell the inspector to make a new window */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
- #endif
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TNewDocCommand : public TNoChangesCommand {
- public: /* Tells the application open a new
- document. */
- virtual pascal void INewDocCommand(CmdNumber itsCmdNumber);
- /* Initialize the NewDocCommand procedurally. */
-
- virtual pascal void DoIt(void);
- /* tell the application open a new document. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TOldDocCommand : public TNoChangesCommand {
- public: /* Tells the application to open an old
- document. */
- virtual pascal void IOldDocCommand(CmdNumber itsCmdNumber);
- /* Initialize the OldDocCommand procedurally. */
-
- virtual pascal void DoIt(void);
- /* tell the application to open an old document. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TCloseWindowCommand : public TNoChangesCommand {
- public:
- /* Tells the application close a window.
- */
- virtual pascal void ICloseWindowCommand(CmdNumber itsCmdNumber, TWindow *itsWindow);
- /* Initialize the CloseWindowCommand procedurally. */
-
- virtual pascal void DoIt(void);
- /* tell the application to close a window. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TQuitCommand : public TNoChangesCommand {
- public: /* Tells the application to quit. */
- virtual pascal void IQuitCommand(CmdNumber itsCmdNumber);
- /* Initialize the QuitCommand procedurally. */
-
- virtual pascal void DoIt(void);
- /* tell the application to quit. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TUndoRedoCommand : public TNoChangesCommand {
- public: /* Tells the application to undo/redo
- the last undoable command */
- virtual pascal void IUndoRedoCommand(CmdNumber itsCmdNumber);
- /* Initialize the UndoRedoCommand procedurally. */
-
- virtual pascal void DoIt(void);
- /* tell the application to undo/redo. */
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TAboutAppCommand : public TNoChangesCommand {
- public: /* Tells the application to show its
- about box. */
- virtual pascal void IAboutAppCommand(CmdNumber itsCmdNumber);
- /* Initialize the AboutAppCommand procedurally. */
-
- virtual pascal void DoIt(void);
- /* tell the application to DoShowAboutApp. */
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TSaveDocCommand : public TNoChangesCommand {
- public: /* Tells the document to save. */
- virtual pascal void ISaveDocCommand(CmdNumber itsCmdNumber, TDocument *itsDocument);
- /* Initialize the SaveDocCommand procedurally. */
-
- virtual pascal void DoIt(void);
- /* tell the document to save. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TRevertDocCommand : public TNoChangesCommand {
- public: /* Tells the document to revert after
- checking with the user */
- virtual pascal void IRevertDocCommand(CmdNumber itsCmdNumber, TDocument *itsDocument);
- /* Initialize the RevertDocCommand procedurally. */
-
- virtual pascal void DoIt(void);
- /* tell the document to revert if the user says OK. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
- class TCommandList : public TSortedList {
- public: /* A list for keeping TCommands ordered by
- priority */
- virtual pascal void ICommandList(void);
- /* Initialize the CommandList procedurally. */
-
- virtual pascal short Compare(TObject *item1, TObject *item2);
- /* Compares Two TCommands based on their priority */
-
- virtual pascal void Insert(TObject *item);
- /* Overridden to guarantee insertion even in low memory and to preserve arrival
- sequence within "Compare" ordering. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields. */
-
- };
-
- /*--------------------------------------------------------------------------------------
- ------------*/
-
- extern pascal Boolean gAlwaysTrackCursor; /* set this to TRUE when you want the
- application to track the cursor even if it
- doesn't stray outside gCursorRgn. */
- extern pascal Boolean gAppDone; /* set this to TRUE when you want the
- application to terminate */
- extern pascal TextStyle gApplicationStyle; /* Application's default text style */
- /*$Push*/ /*$J+*/
- extern "C" TApplication *gApplication; /* the application object */
- /*$Pop*/
-
- #if qDebug
- extern pascal Boolean gAssumeFocused; /* Actually do TView.AssumeFocused checking?
- */
- extern pascal Boolean gBusyTempRgn; /* Is gTempRgn in use? */
- #endif
- extern pascal Boolean gChooserOK; /* if FALSE, user will not be allowed to
- change the printer selection using 'Choose
- Printer' DA while the application is
- alive; if TRUE (the default set in
- InitUMacApp), then printer-change will
- only be disabled during background
- printing. If you want it FALSE in your
- application, the right time to set it is
- after calling InitUMacApp (where it is
- initialized to TRUE) and before calling
- InitPrinting (where, if it's found to be
- FALSE, the low- memory location governing
- is option is poked). In the MultiFinder™
- world this is pretty questionable
- behaviour, though. */
- extern pascal short gClickCount;
- /* number of 'saved up' mouse clicks; handled
- in TApplication.DispatchEvent, ObeyEvent &
- ObeyMouseDown. If a mouseDown, the value
- is that returned by the call to
- TApplication.CountClicks. If a mouseUp,
-
- the value is left alone. Otherwise, set to
- 0. Also set to 0 is the 2 clicks were in
- different parts ofthe window. */
- extern pascal Boolean gClipClaimed;
- /* Used by PerformCommand & ClaimClipboard to
- determine, if DoIt of a cut/copy cmd
- fails, whether the Clipboard had already
- been claimed by the new command or not */
- extern pascal TView *gClipOrphanage;
- /* A view to represent the Clipboard when the
- application can't */
-
- extern pascal TView *gClipUndoView; /* The view previously installed in the
- Clipboard */
-
- extern pascal TView *gClipView; /* The view currently installed in the
- Clipboard */
- extern pascal TWindow *gClipWindow;
- /* The window holding the Clipboard display */
- extern pascal Boolean gClipWrittenToDeskScrap; /* True if the clipboard view has been
- written to the desk scrap. */
- extern pascal Boolean gCouldPrint; /* whether Printer code is accessible to the
- application */
- extern pascal TPrintHandler *gCurrPrintHandler; /* If printing, this is set to the print
- handler. Nil if not printing. */
- #if qDebug
- extern pascal Boolean gDebugPrinting; /* simple toggle for debugging printing */
- #endif
- extern pascal TList *gDocList; /* list of documents */
- extern pascal Boolean gDrawingPictScrap; /* TRUE if a view's Draw routine is being
- called in order to create PICT data in the
- Desk Scrap; your View.Draw can check this
- routine, and insert PictComments as
- appropriate if it wishes to have them in
- the Picture in the Desk Scrap */
- extern pascal TView *gDrawingPictScrapView;
- /* the view being currently drawn in the PICT
- scrap ??? this stuff is a good candidate
- for a small change to the view
- architecture to more easily allow
- providing alternate drawing environments */
- #if qExperimentalAndUnsupported
- extern pascal Boolean gEnableDoubleBuffering; /* TRUE to enable automatic double buffering
- when drawing/scrolling views */
- #endif
- extern pascal Str255 gErrorParm3; /* This is used as the last argument to
- ParamText in ErrorAlert, if ErrorAlert
- displays one of the standard alerts. (This
- string will replace ^3 in those alerts.)
- ErrorAlert also sets this to '' when
- called. You can use this to parameterize
- the automatic alerts that MacApp displays.
- For example, TDocument.ReadFromFile sets
- this to the document name. */
- extern pascal short gEventLevel; /* A count of the number of nested calls to
- PollEvent. */
- #if qDebug
- extern pascal Boolean gExperimenting; /* simple toggle for enabling/disabling
- experimental features */
- #endif
- extern pascal WindowRecord gFakeWindow; /* In MacApp 2.0 and earlier, this was
- initialized with OpenPort, or OpenCPort,
- and by setting its ControlList to NIL.
- This was NOT a real window, just a port.
- In MacApp 2.0.1 and later, this is a
- real window. It's ignored in routines that
- iterate over the windowList. */
-
- extern pascal short gFileCount; /* # files to open/print from finder; set in
- Init2 */
- extern pascal Boolean gFinderPrinting;
- /* TRUE if the Finder started the App up just
- for printing docs */
- extern pascal TView *gFocusedView; /* the view that is currently focused */
- extern pascal TList *gFreeWindowList; /* list of free-standing (documentless)
- windows */
- extern pascal Boolean gGotClipType; /* True if we can paste the data in the
- clipboard */
- extern pascal TEvtHandler *gHeadCohandler; /* head of linked list of global co-handlers
- */
- extern pascal IdlePhase gIdlePhase; /* The current idle phase */
- extern pascal Boolean gInBackground; /* True if app is currently in background */
- extern pascal Boolean gInitialized; /* Set to TRUE at the end of IApplication */
- #if qDebug
- extern pascal Boolean gIntenseDebugging;
- /* debugging toggle for intensive debugging */
- #endif
- extern pascal short gLastClickPart; /* the list window part clicked in-used for
- double click detection */
- extern pascal long gLastDeskAcc;
- /* time of the most recent possible excursion
- to a a Desk Accessory */
- extern pascal Point gLastMsePt; /* coordinates of mouse in last event passed
- to TApplication.CountClicks */
- extern pascal long gLastUpTime; /* time of last mouse up event passed to
- TApplication.ObeyEvent */
- extern pascal VPoint gLongOffset; /* Used in focusing */
- extern pascal long gLowSpaceInterval; /* If >= 0, the frequency (in Ticks) with
- which MacApp displays a low space alert.
- (Defaults to kLowSpaceInterval.) If < 0,
-
- MacApp doesn't display an alert. */
- extern pascal Ptr gMacAppAlertFilter; /* the default filter proc. Will be
- automatically set to point to
- MacAppAlertFilter. Set this to nil in your
- code if you don't want it or call it from
- your own filter proc if you just want to
- add behavior. Someday we will fix all this
- to be Object based. */
- extern pascal Boolean gInFilter; /* Flag that is set when we are in the
- MacAppAlertFilter, used to indicate if we
- should re-enter MacApp to handle updates
- or not */
- extern pascal Boolean gInhibitNestedHandling; /* TRUE if Failure was executed and the
- outer- most event loop has not been
- reached or the ErrorAlert routing has not
- yet shown the failure to the user. Also
- may be set to TRUE to inhibit continued
- operation of MacApp Activate/Update
- handling and idling during MacAppAlerts. */
- extern pascal short gMainEventMask; /* Event mask used in main event loop.
- Initialized by InitUMacApp. */
- extern pascal OSType gMainFileType; /* principal file type opened/printed by
- application; set in
- TApplication.IApplication; by default,
-
- TApplication.SFGetFilters returns a list
- of just this */
- extern pascal short gMBarDisplayed; /* menus that are read in and installed in
- menu bar */
- extern pascal short gMBarHierarchical; /* menus that pop up when a menu item is
- choosen */
- extern pascal short gMBarNotDisplayed;
- /* menus that are read in but not installed */
- extern pascal ScrapStuff gNewScrapStuff; /* the current ScrapStuff record used in
- tracking the scrap */
- extern pascal long gNextSpaceMsg;
- /* time when next low space message should be
- displayed */
- extern pascal TPrintHandler *gNullPrintHandler; /* handles printing-relating messages for
- views which don't print */
- extern pascal short gNumUntitled; /* The number to assign to the next Untitled
- document (assuming that the app provides a
- template for filling in the number. You
- must change STR# resource with ID 0 /
- index 3 to read (for example)
- Untitled-<<<#>>>. */
- extern pascal TCommand *gNoChanges; /* Value to return when the handler doesn't
- return a command. You can just use NIL
- now. (Left in for compatibility (2.0) */
- extern pascal Boolean gOldChooserFlag; /* The state of the chooser alert flag when
- the application started up. */
- extern pascal ScrapStuff gOldScrapStuff; /* the last ScrapStuff record used in
- tracking the scrap */
- extern pascal VHSelect gOrthogonal[2]; /* An Orthogonal set of VHSelects.
- gOrthogonal[v] = h and
- gOrthogonal[h] = v */
- extern pascal VPoint gPageOffset; /* offset in view of page being printed */
- extern pascal ResType gPrefClipType;
- extern pascal TPrintHandler *gPrintHandler; /* a global print-handler object for use in
- some standard printing-related activities;
- this is initialized to be just a reference
- to gNullPrintHandler, but if you call
- InitPrinting, that will install a
- non-trivial print-handler here… */
- extern pascal Boolean gPrinting; /* true if currently Printing */
- #if qDebug
- extern pascal Boolean gReportEvt; /* debugging toggle for reporting events */
- extern pascal Boolean gReportMenuChoices; /* debugging toggle for tracing cmds */
- extern pascal short gRsrcCheck; /* debugging toggle for checking resource
- usage */
- #endif
- extern pascal FocusRec gSaveFocusRec; /* a place to save off the focus to speed up
- scrolling*/
-
- extern pascal ResType gSignatures[32];
- /* Standard object signatures */
- extern pascal ObjClassID gSignatureIds[32]; /* corresponding standard
- object ClassIds */
- extern pascal short gSignatureCount; /* count of standard signatures stored */
-
- extern pascal Point gStdHysteresis; /* standard hysteresis used in
- TCommand.ICommand */
- extern pascal short gStdStaggerCount; /* Used to stagger windows created from
- templates */
- extern pascal Rect gStdWMoveBounds; /* standard boundsRect to pass to DragWindow
- Toolbox routine */
- extern pascal Rect gStdWSizeRect; /* standard sizeRect to pass to GrowWindow
- Toolbox routine */
- extern pascal Rect gStdWScreenRect;
- /* Used to force a window onto the screen. If
- the window is not in the GrayRgn, then at
- least one corner of the window must lie
- within gStdWScreenRect. */
-
- extern pascal Boolean gSysWindowActive; /* TRUE if the front window is a system
- window */
- extern pascal TextStyle gSystemStyle; /* System's default text style */
- extern pascal TEvtHandler *gTarget;
- /* the TEvtHandler that gets the first chance
- at DoCommand, DoSetupMenu, DoKeyCommand,
-
- Idle; should never be NIL -- If you do not
- want your own target set this to the
- application object */
-
- extern pascal RgnHandle gTempRgn; /* gTempRgn is a temporary RgnHandle created
- in InitUMacApp. When debugging: before
- using gTempRgn, call UseTempRgn and when
- done call DoneWithTempRgn; this ensures
- that 2 routines do not try to use gTempRgn
- and the same time */
- #if qDebug
- extern pascal Boolean gTraceIdle; /* allow tracing through idle */
- #endif
- extern pascal Boolean gUndoState; /* are we in undo or redo */
- extern pascal CmdNumber gUndoCmd; /**/
- #if qDebug
- extern pascal Str255 gUsedBy; /* The routine using gTempRgn */
- #endif
- extern pascal Boolean gVarClipPicSize; /* if TRUE, Pictures in the Clipboard are
- treated as variable size, depending on the
- window size; if FALSE (default), then
- pictures in the Clipboard are drawn and
- pasted ??? actual size */
- #if qDebug
- extern pascal Boolean gWasTrcEnable; /* Used to store old tracing state across
- idleBegin/idleEnd calls to Idle */
- #endif
- extern pascal ResType gWResSignature; /* Signature used by TView.WRes */
- extern pascal Str255 gWResType; /* Type used by TView.WRes */
- extern pascal GrafPtr gWorkPort; /* Pointer to a graf port that is created
- during initialization */
-
- /* Pascal doesn't have structured constants so… */
- extern pascal Rect gZeroRect; /* SetRect(gZeroRect, 0, 0, 0, 0); */
- extern pascal Point gZeroPt; /* SetPt(gZeroPt, 0, 0); */
- extern pascal VPoint gZeroVPt; /* SetVPt(gZeroVPt, 0, 0); */
- extern pascal VRect gZeroVRect; /* SetVRect(gZeroVRect, 0, 0, 0, 0); */
-
- /* These are really private but, they're here in case access is needed. */
- extern pascal StringHandle pCopyright;
- extern pascal TrapPatch pETSPatch; /* patch for ExitToShell */
- extern pascal FailInfo pFi; /* Outermost failure handler */
-
- /*--------------------------------------------------------------------------------------
- ------------*/
-
- /* D E B U G G I N G */
-
- #if qDebug
-
- extern pascal void DoneWithTempRgn(void);
- /* Indicates that gTempRgn is no longer in use. Call this only if qDebug is true. */
-
- extern pascal void EntDebugger(Boolean entering);
- /* Call to enter the MacApp Debugger */
-
- extern pascal void UseTempRgn(StringPtr byWhom);
- /* Call this when you are about to use gTempRgn and qDebug is true. Used with DoneWithTe
- mpRgn
- will prevent you from trying to use gTempRgn from two places at the same time. */
- #endif
-
- extern pascal long LookupSymbol(StringPtr sym);
- /* Call to see if anyone knows a reference for the given symbol */
-
- extern pascal void NotYetImplemented(StringPtr where);
- /* Signals the notYetImplemented failure which when caught puts up an alert saying
- "Not Yet Implemented" and in debug WriteLns where. */
-
- /* W I N D O W S */
-
- extern pascal GrafPtr FreeIfWMgrWindow(GrafPtr w, Boolean dispose);
- /* Calls DisposeWindow if dispose is true, else calls CloseWindow. Does nothing if w
- is nil.
- Returns NIL for convenient assignment back to the reference passed in. */ /* Preferred */
-
-
- extern pascal void FreeWMgrWindow(GrafPtr w, Boolean dispose);
- /* Left in for compatibility (2.0) */
-
- extern pascal short GetWindowVariant(GrafPtr theWindow);
-
- extern pascal TWindow *NewPaletteWindow(short itsRsrcID, Boolean wantHScrollBar, Boolean
- wantVScrollBar, TDocument *itsDocument, TView *itsMainView, TView *itsPaletteView, short
- sizePalette, VHSelect whichWay);
- /* Utility for creating MacDraw-like windows with 1 non-scrolling palette along the left
- edge
- (whichWay = h), or a non-scrolling status area at the top of the window (whichWay = v), and
- a main view that may or may not scroll. Signals Failure if the window could not be created.
- */
-
- extern pascal TWindow *NewSimpleWindow(short itsRsrcID, Boolean wantHScrollBar, Boolean
- wantVScrollBar, TDocument *itsDocument, TView *itsView);
- /* Utility for creating simple windows that contain 1 view and may or may not scroll. Si
- gnals
- Failure if the window could not be created. */
-
- extern pascal TWindow *NewTWindow(short itsRsrcID, TDocument *itsDocument);
- /* Utility for creating a window object. Used within NewPaletteWindow & NewSimpleWindow.
- SIgnals Failure if the window could not be created. */
-
- extern pascal TWindow *NewTemplateWindow(short viewRsrcID, TDocument *itsDocument);
- /* Creates a window using a 'WIND' resource and a 'view' template. */
-
- extern pascal Boolean ParseTitleTemplate(StringPtr itsTemplate, short *preDocname, short *constTitle
- );
- /* Used in TWindow.IWindow to parse the template for window titles. Returns TRUE if it c
- hanged
- the template. preDocname is start of document name in string; constChars is total #
- characters of window title that are constants. (These values are fixed regardless of the
- document name.) If preDocname is 0, then the entire title is constant. */
-
- extern pascal Boolean SubstituteInTitle(StringPtr title, StringPtr newStuff, short preDocname, short
- constTitle);
- /* Substitutes newStuff into the template as parsed by ParseTitleTemplate; returns TRUE if a
- substitution was made. */
-
- /* C L I P B O A R D */
-
- extern pascal void CanPaste(ResType aClipType);
- /* Call this in your SetUpMenus code to register an ability to paste a particular type of
- Clipboard data */
-
- extern pascal OSErr PutDeskScrapData(ResType aResType, Handle aDataHandle);
- /* Call this from your TCommand method 'WriteToDeskScrap' (for a Command which changes the
- Clipboard) to write out data to the actual Desk Scrap. The return code from the Scrap
- Manager is returned as the function value -- will be noErr unless something went wrong.
- This procedure leaves aDataHandle UNLOCKED. Rather than calling this, you can call the
- ToolBox routine PutScrap yourself */
-
- /* E R R O R S */
-
- extern pascal void ErrorAlert(OSErr err, long message);
- /* Displays an error alert box. The message displayed in the alert is constructed base upon
- err and message, as described in the "Failure Handling" section of the "Cookbook" chapter
- of the MacApp manual. */
-
- extern pascal Boolean LookupErrString(short value, short resourceID, StringPtr str);
- /* Looks up an error value in an 'errs' resource and returns TRUE if found. resourceID s
- hould
- be that of a MacApp errs resource; we do the lookup first in errAppTable+resourceID, which
- applications can use to override or extend the MacApp table. If the value is not found, str
- will be empty. */
-
- extern pascal short MacAppAlert(short alertID, Ptr filterProc);
- /* Does SetCursor(arrow) before calling Alert. */
-
- extern pascal void StdAlert(short alertID);
- /* no filterProc, reply ignored */
-
- /* V I E W R E S O U R C E U T I L I T I E S */
-
- extern pascal void RegisterStdType(StringPtr typeName, ResType signature);
- /* Associates the given class with a signature. */
-
- extern pascal TObject *NewStdObject(ResType signature);
- /* Returns the prototype object for the given signature. */
-
- extern pascal ViewRsrcHandle NewViewRsrc(void **p);
- /* Convenience routine to create a new view resource template handle. Passes back in "p" the
- pointer to the first template entry. */
-
- extern pascal void DoneViewRsrc(void *viewRsrc, long lastPtr);
- /* Cuts back the handle to the proper length, based on lastPtr which should be the addre
- ss of
- the next template entry. */
-
- extern pascal Ptr ExpandPtr(void *viewRsrc, long *p, long offset);
- /* Bumps size of view resource if necessary to add a new template. Amount to bump is set
- to at
- least kViewRsrcExpandAmt over the current size. "p" is offset to point to the next
- available position for a new template. Returns the old value of p before it was updated. */
-
- extern pascal Ptr ExpandPtrWStr(void *viewRsrc, long *p, long offset, long len);
- /* Bumps size of view resource if necessary to add a new template which ends with a
- variable length string, the length of which is passed in len.
- Returns the old value of p before it was updated. */
-
- extern pascal void OffsetPtr(long *p, long offset);
- /* Adds offset to p, forcing word alignment.*/
-
- extern pascal void OffsetPtrWStr(long *p, long offset);
- /* Adds offset to p, taking length of trailing variable length string into account, forcing
- word alignment.*/
-
- /* M I S C E L L A N E O U S */
-
- extern pascal void ApplicationBeep(void);
- /* If gApplication is not NIL just calls gApplication.Beep else it does a SysBeep.
- Removes a circular reference for UFailure.*/
-
- pascal Boolean CallAlertFilter(GrafPtr theDialog, EventRecord *theEvent, short *itemHit, Ptr
- theAlertFilter)
- = {0x205F, /* MOVE.L (A7)+,A0 */
- 0x4E90}; /* JSR (A0) */
- /* Lets you call the alert filter specified in theAlertFilter. Useful for providing
- your own alert filter behaviour and then passing on to MacApp's */
-
- extern pascal GrafPtr GetNewCenteredDialog(short dialogID, Ptr dStorage, GrafPtr behind);
- /* The same as GetNewDialog except it centers the dialog on the screen and sets the curs
- or to
- an arrow. */
-
- extern pascal void GetFocus(FocusRec *theFocusRec);
- /* gets the current focus into a focusrec. The focusrec.clipRgn must be a valid rgn usef
- ul for
- saving and restoring the focus behind MacApp's back.*/
-
- extern pascal void SetFocus(FocusRec *theFocusRec);
- /* sets the current focus from a focus rec */
-
- extern pascal void GetTextStyleFontInfo(TextStyle *theTextStyle, FontInfo *theFontInfo);
- /* Returns the FontInfo record for the font/face/size specified in theTextStyle. Uses
- a temporary port so you don't have to. */
-
- extern pascal void ExitMacApp(void);
- /* Call this if for some reason you want to immediately exit the application. It calls
- gApplication.Terminate, cleans up some other internal stuff, and then calls ExitToShell.
- (Normally, you would not call this, because MacApp takes care of terminating the
- application.)*/
-
- extern pascal void InitUMacApp(short callsToMoreMasters);
- /* Initialize the UMacApp unit call this in your program after calling: InitToolBox and
- ValidateConfiguration. */
-
- extern pascal void InstallIfPrintHandler(TPrintHandler *aPrintHandler, TView *aView);
- /* Install a clone of aPrintHandler into the view if aPrintHandler is not the
- same as the null print handler. (Typically if printing is initialized.) This
- lets us install a print handler if printing is being used in the application
- and do NOTHING if it is not. */
-
- extern pascal Boolean MacAppAlertFilter(GrafPtr theDialog, EventRecord *theEvent, short *itemHit);
- /* Default alert filter used throughout MacApp. Lets you answer yes and no to dialogs with
- keystrokes. Handles "cmd-." and escape. If the alert has not been called in a fa
- ilure sequence
- then the application also handles update and activate events and idles. */
-
- extern pascal RgnHandle MakeNewRgn(void);
- /* Calls NewRgn, then FailNIL*/
-
- extern pascal Boolean RectIsVisible(Rect *r);
- /* Determine if a rect is visible in the current grafport. */
-
- extern pascal void SetHLPenState(HLState fromHL, HLState toHL);
- /* Set the pen state for highlighting by XOR, given the highlight transition. You can us
- e this
- if you use Paint<X> or Frame<X> or line drawing for your highlighting. */
- /* ??? Add a pattern parameter or make a helper routine that has a pattern parameter ??? */
-
- extern pascal void FinderSegProc(void);
- /* This is a dummy procedure to allow us to find the Finder segment */
-
- extern pascal void CleanupMacApp(void);
- /* Called as the final step of TApplication.Run */
- #endif
-
- extern pascal void VisibleRect(Rect *r);
- /* Get the currently visible rectangle as defined by thePort clip region */
-
-